f



Easy query I can't do? Can you help?

If I have a table as such..

Name   Age
--------------
Eric        1
Sarah    2
Jeff        1
Ted        4
Mary       1
Sam       3


How can I do a single sql query that displays the following

Age 1   Age 2  Age 3   Age 4
3           1         1          1


TIA 


0
asdf
2/15/2006 6:44:18 PM
comp.database.oracle 721 articles. 0 followers. Post Follow

2 Replies
530 Views

Similar Articles

[PageSpeed] 12

"asdf" <scottphelps@noemailplease.com> wrote in message
news:6EKIf.33213$H71.32701@newssvr13.news.prodigy.com...
> If I have a table as such..
>
> Name   Age
> --------------
> Eric        1
> Sarah    2
> Jeff        1
> Ted        4
> Mary       1
> Sam       3
>
>
> How can I do a single sql query that displays the following
>
> Age 1   Age 2  Age 3   Age 4
> 3           1         1          1
>
>
> TIA
>
>
select
    (select count(*) from age where age=1) age_1,
    (select count(*) from age where age=2) age_2,
    (select count(*) from age where age=3) age_3,
    (select count(*) from age where age=4) age_4 from dual;


0
Jim
2/16/2006 1:48:21 AM
"Jim Kennedy" <jim dot scuba dot kennedy at gee male dot com> wrote in 
message news:V-OdnUJtbpwDR27eRVn-pw@comcast.com...
>
> "asdf" <scottphelps@noemailplease.com> wrote in message
> news:6EKIf.33213$H71.32701@newssvr13.news.prodigy.com...
>> If I have a table as such..
>>
>> Name   Age
>> --------------
>> Eric        1
>> Sarah    2
>> Jeff        1
>> Ted        4
>> Mary       1
>> Sam       3
>>
>>
>> How can I do a single sql query that displays the following
>>
>> Age 1   Age 2  Age 3   Age 4
>> 3           1         1          1
>>
>>
>> TIA
>>
>>
> select
>    (select count(*) from age where age=1) age_1,
>    (select count(*) from age where age=2) age_2,
>    (select count(*) from age where age=3) age_3,
>    (select count(*) from age where age=4) age_4 from dual;
>
>

Intresting thanks! 


0
asdf
2/16/2006 7:38:56 PM
Reply: