Re: problem in with clause: if table1 is empty select from table2

From: <nova1427_at_gmail.com>
Date: Sun, 30 Mar 2008 04:11:55 -0700 (PDT)
Message-ID: <2a6484fb-ff93-407b-8e3f-cb9992437ee7@a23g2000hsc.googlegroups.com>


On Mar 30, 12:59 pm, Urs Metzger <u..._at_ursmetzger.de> wrote:
> nova1..._at_gmail.com schrieb:> Please help me to write query like this
>
> > WITH table_not_empty AS
> > (
> >    if (SELECT * FROM Table1) is not empty return it_self
> >    else return (SELECT * FROM Table2)
> > )
>
> WITH table_not_empty AS
> (
>     SELECT 'it_self' FROM Table1
>      WHERE ROWNUM = 1
>     UNION
>     SELECT * FROM Table2
>      WHERE NOT EXISTS(SELECT NULL FROM Table1)
> )
>
> HtH, Urs Metzger

Very good idea

thanks Received on Sun Mar 30 2008 - 06:11:55 CDT

Original text of this message