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!

Case statement help

Status
Not open for further replies.

michaela18

Technical User
Sep 9, 2009
37
US
How can I write a case statement for:

nullif(CONCAT((SUM(Sales.sales)/SUM(sales.volumn))*100,'%'),0) AS ATC ?


I want to pull 'ATC' but with different where statements. But I don't know how to put that as a case statement like nullif ( case when ???? I have no idea.
 
Code:
SELECT NULLIF(
              CASE WHEN Condition1 
                        THEN Result1
                   WHEN Condition2
                         THEN Result2
               ...
               ELSE DefaultResult END, 0) AS ATC
But that is only if you use that expression in Fields part of the query. If you want to use it in WHERE part then you should skip AS ATC part


Borislav Borissov
VFP9 SP2, SQL Server 2000,2005 & 2008.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top