Select CASE

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



I'm a newbie trying to learn. Can someone help me with this. I'm trying to
do this in SQL2005.

This works just fine, except I want a Case where if the return Value is NULL
or blank or nothing, then give me a digit of zero (0) else give me my
number. I never get the (0) and I don't know why.

Here is my Select Statement:
***************************
SELECT SUM(CASE FDetail.Amount WHEN NULL THEN 0 ELSE FDetail.Amount END)
AS Withdrawal
FROM SQL2000.PartnerData.dbo.FDetail AS FDetail INNER JOIN
LpClients ON FDetail.PshipID = LpClients.PshipID AND
FDetail.PartnerID = LpClients.PartnerID
WHERE (FDetail.ItemCode = N'BegWd') AND (FDetail.Period <= @EndDate) OR
(FDetail.ItemCode = N'BegAssign') OR
(FDetail.ItemCode = N'EndWd') OR
(FDetail.ItemCode = N'EndAssign')
GROUP BY LpClients.LpClientsID
HAVING (LpClients.LpClientsID = @LpClientsID) AND (SUM(CASE
FDetail.Amount WHEN NULL THEN 0 ELSE FDetail.Amount END) < 0)

*************************
Thanks!


.



Relevant Pages

  • Re: display a string X times?
    ... instead of just as a digit. ... I figured (as a newbie) I could just define ... As there are only 10 different scores, you could cache them in an array so you don't create a new String object every time. ...
    (comp.lang.java.help)
  • display a string X times?
    ... I'm being asked to represent an integer score value in asterisks ... instead of just as a digit. ... I figured (as a newbie) I could just define ...
    (comp.lang.java.help)
  • Re: Grounding - Can Somebody Please Offer an Explanation?
    ... No problem being a newbie at something. ... We're all born wet, nekid, 'n stupid, ... and had to learn whatever from zero. ... Hah thanks Bob I don't feel QUITE as bad for asking all these newbie ...
    (rec.radio.shortwave)
  • Re: display a string X times?
    ... instead of just as a digit. ... I figured (as a newbie) I could just define ... My other idea is using a while loop, but I think this could be a bit unwieldy, for the scale of the program it's for. ... Carl. ...
    (comp.lang.java.help)
  • Re: WTL and lost DrawItem Msg
    ... "newbie" wrote in message ... > Sry ment ListView_SetItemCount. ... It should be zero. ... "For every complex problem, there is a solution that is simple, neat, ...
    (microsoft.public.vc.atl)