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" <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 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 |
![]() |