Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

making categories from a table 1

Status
Not open for further replies.

cihatkarli

Programmer
May 22, 2007
18
0
0
TR
i have cell named age in my table.

i want a query like this.

ages between 18-25 will be in first column 26-30 in second 31-35 in third.

is it possible?

thanks.
 
yes, it is
Code:
select foo
     , count(
         case when age between 18-25 
              then 'count this one'
              else null end ) as age_18_25
     , count(
         case when age between 26-30 
              then 'count this one'
              else null end ) as age_26_30
     , count(
         case when age between 31-35 
              then 'count this one'
              else null end ) as age_31_35
  from daTable
group
    by foo
:)

r937.com | rudy.ca
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top