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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create a Case... When.. As ...

Status
Not open for further replies.

JCooL

Programmer
Joined
Oct 21, 2001
Messages
89
Location
US
How do i create a several condiction in a SQL's View like a field?

i.e.

CASE WHEN [age]<=20 THEN [Expr3]ELSE 0 END AS Age1
CASE WHEN [age]>=30 THEN [Expr3]ELSE 0 END AS Age2

i test this but unly with the first line and is perfect...

Thanx to Advanced
 

You'll probably want to summarize on some key columns.

Sum(CASE WHEN [age]<=20 THEN [Expr3] ELSE 0 END) AS Age1
Sum(CASE WHEN [age]>=30 THEN [Expr3] ELSE 0 END) AS Age2
.
.
.
GROUP BY keycol1, keycol2

Terry L. Broadbent
FAQ183-874 contains tips for posting questions in these forums.
NOTE: Reference to the FAQ is not directed at any individual.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top