There is a function in SQL called IsNull which replaces a NULL result with
whatever value you specify.

Try doing this in the first line of your statement:
SELECT IsNull(Count(OrderDate),0) AS TotalOrdersPerDay

That way if the result set is NULL it will output a 0.

Ali
-----Original Message-----
From: Che Vilnonis [mailto:[EMAIL PROTECTED] 
Sent: Friday, March 04, 2005 2:23 PM
To: CF-Talk
Subject: OT: SQL Case Question?

I'm trying to output total orders by day of the week.

SELECT Count(OrderDate) AS TotalOrdersPerDay
FROM    Orders
WHERE Status = 'SHIPPED'
        AND (OrderDate BETWEEN '#VarStartDate# 00:00:01' AND '#VarEndDate#
23:59:59')
GROUP BY Datepart(dw,OrderDate)
ORDER BY Datepart(dw,OrderDate) ASC

This code works great, for the most part. How would I change this code so
that if there were NO orders for a particular day, the query would return a
result of zero [0] and not null or whatever it returns when there is no
result? Does this make sense? I just don't want to have <td> cells with
nothing in them.

Thanks, Che




~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Discover CFTicket - The leading ColdFusion Help Desk and Trouble 
Ticket application

http://www.houseoffusion.com/banners/view.cfm?bannerid=48

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:197545
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to