Code:
SELECT * from table_a where id=p_id the order by decode (function, ' ASC ', 1, ' desc ', -1) *jsny;
Control the attempted access time:
6. Code:
Create View ...
As
Select ... from where exists (select X from dual where sysdate>=8:00am and sysdate<=5:00pm)
Magical Decode Realization Sort
Code:
SELECT * FROM TabName
Order by decode (mode, ' FIFO ', 1,-1) *to_char (RQ, ' Yyyymmddhh24miss ');
SELECT * FROM TabName
Order by decode (mode, ' FIFO ', Rq-sysdate, SYSDATE-RQ)
Find out the number of workdays in a certain period:
Code:
Select COUNT (*)
From (select Rownum-1 rnum
From All_objects
where RowNum <= to_date (' 2002-02-28 ', ' yyyy-mm-dd ')-To_date (' 2002-
02-01 ', ' yyyy-mm-dd ') +1)
where To_char (to_date (' 2002-02-01 ', ' yyyy-mm-dd ') +rnum-1, ' D ') not
In (' 1 ', ' 7 ')
I think it's a classic statement to query for duplicate records.
Code:
Select Rowid,bdsszd from Badwdj a where A.rowid!= (select Max (ROWID) from BADWDJ b where A.bdsszd =b.bdsszd)
It is the extension of a lot of useful statements, such as yesterday to answer the question of the sort of others
Code:
Select Id,bdsszd from Badwdj a WHERE a.id = (select Max (id) to BADWDJ b where a.bdsszd =b.bdsszd) Order by ID
Query for tree-structured tables:
Code:
Select id,parent_id from Parent_child
Connect by Prior ID = parent_id
Start with id = 1;