dbTalk Databases Forums  

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

comp.database.oracle comp.database.oracle


Discuss Easy query I can't do? Can you help? in the comp.database.oracle forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
asdf
 
Posts: n/a

Default Easy query I can't do? Can you help? - 02-15-2006 , 12:44 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



Reply With Quote
  #2  
Old   
Jim Kennedy
 
Posts: n/a

Default Re: Easy query I can't do? Can you help? - 02-15-2006 , 07:48 PM







"asdf" <scottphelps (AT) noemailplease (DOT) com> wrote

Quote:
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;




Reply With Quote
  #3  
Old   
asdf
 
Posts: n/a

Default Re: Easy query I can't do? Can you help? - 02-16-2006 , 01:38 PM




"Jim Kennedy" <jim dot scuba dot kennedy at gee male dot com> wrote in
message news:V-OdnUJtbpwDR27eRVn-pw (AT) comcast (DOT) com...
Quote:
"asdf" <scottphelps (AT) noemailplease (DOT) com> wrote in message
news:6EKIf.33213$H71.32701 (AT) newssvr13 (DOT) 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!




Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.