Flexible use of numeric type by

Source: Internet
Author: User

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;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.