Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Count and IsNull

Author  Topic 

jrockfl
Posting Yak Master

223 Posts

Posted - 2004-10-21 : 14:08:27
I'm trying to return 0 for discount, but im getting a null.
I tried this, but doesnt return anything..

SELECT IsNull(COUNT(Discount_pct),0) As discount, prod_cat
FROM OELINHST_SQL
WHERE Discount_pct = '100'
AND OELINHST_SQL.prod_cat = 'M37'
GROUP BY prod_cat

JimL
SQL Slinging Yak Ranger

1537 Posts

Posted - 2004-10-21 : 14:18:53
Did you check to make sure there is actual data that meets the criteria of your where clause?

Jim
Users <> Logic
Go to Top of Page

rockmoose
SQL Natt Alfen

3279 Posts

Posted - 2004-10-21 : 14:21:15
Do you have any rows meeting the criteria ?
"WHERE Discount_pct = '100'
AND OELINHST_SQL.prod_cat = 'M37'"

If not you could try the GROUP BY ALL clause.

rockmoose
/* Chaos is the nature of things...Order is a lesser state of chaos */
Go to Top of Page

rockmoose
SQL Natt Alfen

3279 Posts

Posted - 2004-10-21 : 14:21:41


rockmoose
/* Chaos is the nature of things...Order is a lesser state of chaos */
Go to Top of Page

jrockfl
Posting Yak Master

223 Posts

Posted - 2004-10-21 : 21:15:38
There was no data returned because of the prod_cat. I found my problem. Thank you for helping.
Go to Top of Page
   

- Advertisement -