Home > Archive > Oracle Databases > February 2006 > Easy query I can't do? Can you help?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

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

2006-02-15, 1:24 pm

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


Jim Kennedy

2006-02-15, 8:25 pm


"asdf" < scottphelps@noemailp
lease.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;


asdf

2006-02-17, 7:27 am


"Jim Kennedy" <jim dot scuba dot kennedy at gee male dot com> wrote in
message news:V-OdnUJtbpwDR27eRVn-pw@comcast.com...
>
> "asdf" < scottphelps@noemailp
lease.com> wrote in message
> news:6EKIf.33213$H71.32701@newssvr13.news.prodigy.com...
> 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!


Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com