Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: Need help with a SQL query

Re: Need help with a SQL query

From: Anurag Varma <avdbi_at_hotmail.com>
Date: Thu, 27 Mar 2003 01:41:19 GMT
Message-ID: <3Fsga.1837$ec3.1296@news01.roc.ny.frontiernet.net>


Not wanting to nitpick .. and it does not matter much in this case. But imho using "union all" is better when you don't really need union.

Anurag

"Joseph Wilson" <me_at_home.now> wrote in message news:qWrga.2735$2x2.1154317_at_dca1-nnrp1.news.algx.net...
> select 'a' as ATTRIBUT , count(*) as no from table1 where a is not null
> UNION
> select 'b' as ATTRIBUT, count(*) as no from table1 where b is not null
> UNION
> select 'c' as ATTRIBUT, count(*) as no from table1 where c is not null
>
>
> "Anders Windelhed" <anders_at_underlandstudios.com> wrote in message
> news:txqga.30193$oe.93724_at_amstwist00...
> > I need help with a SQL query...
> >
> > I have three queries:
> >
> > (select 'a' as ATTRIBUT , count(*) as no from table1 where a is not null)
> >
> > (select 'b' as ATTRIBUT, count(*) as no from table1 where b is not null)
> >
> > (select 'c' as ATTRIBUT, count(*) as no from table1 where c is not null)
> >
> > the results from these queries looks like this
> >
> > attribut no
> > a 34
> >
> > and so on...
> >
> > I would like to combine into one result table like this
> >
> > attribut no
> > a 34
> > b 334
> > c 23
> >
> > I know that it would be much easier to create a query that gives the
> result
> > like this
> >
> > a b c
> > 34 334 23
> >
> > but that won't solve my problem =(
> >
> > Any suggestions?
> >
> > Best regards
> >
> > Anders
> >
> >
>
>
Received on Wed Mar 26 2003 - 19:41:19 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US