Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Need help with a SQL query
>>>>> "Joseph" == Joseph Wilson <me_at_home.now> writes:
Joseph> select 'a' as ATTRIBUT , count(*) as no from table1 where a Joseph> is not null UNION select 'b' as ATTRIBUT, count(*) as no from Joseph> table1 where b is not null UNION select 'c' as ATTRIBUT, Joseph> count(*) as no from table1 where c is not null
While the answer does give what the OP asked for, I have a feeling it won't be the result wanted. Its likely a group by may be needed on each statement, otherwise they will have one row for each row returned with a different value for the attribute, but the same value for the count.
Tim
Tim
Joseph> "Anders Windelhed" <anders_at_underlandstudios.com> wrote in
Joseph> 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
Joseph> result
>> like this
>>
>> a b c 34 334 23
>>
>> but that won't solve my problem =(
>>
>> Any suggestions?
>>
>> Best regards
>>
>> Anders
>>
>>
-- Tim Cross The e-mail address on this message is FALSE (obviously!). My real e-mail is to a company in Australia called rapttech and my login is tcross - if you really need to send mail, you should be able to work it out!Received on Fri Mar 28 2003 - 03:26:57 CST
![]() |
![]() |