Wednesday, November 10, 2010

Use With Clause in Sql

So here I am writing even more documentation for my current Gig, and thinking once again, why not post it to OraFAQ and get double duty out of the document. So here is a discussion of the WITH clause that comes with the SELECT statement now. It is easy to use, and handy as all get out, but seems many people have not yet noticed it. Hmm... a SELECT statement that does not start with SELECT.

I like examples as a learning tools, so lets start off with some seemingly silly code.


WITH
stupid_is_as_stupid_does as (
select *from tbldual
)
select *
from stupid_is_as_stupid_does
/

tbldual
----------
X

1 row selected.


Note : You Must be select the With table after the execution o.w. you will get error like ) bracket not closed

No comments:

Post a Comment