Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL Statement in Range
Message
From
05/02/2001 15:44:13
 
 
To
05/02/2001 13:14:03
Coann Teng
Computer Infobase System S/B
Kuala Lumpur, Malaysia
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Miscellaneous
Thread ID:
00472564
Message ID:
00472664
Views:
30
You can do this with a derived table

SELECT
label,
COUNT(*)
FROM (
SELECT
CASE
WHEN Age BETWEEN 1 AND 20 THEN '1-20'
WHEN Age BETWEEN 21 AND 40 THEN '21-40'
WHEN Age BETWEEN 41 AND 60 THEN '41-60'
ELSE '>60'
END AS label
FROM thetable )
GROUP BY label

-Mike
Michael Levy
MCSD, MCDBA
ma_levy@hotmail.com
Previous
Reply
Map
View

Click here to load this message in the networking platform