Count >30 or if none show 0

  • Thread starter instereo911 via AccessMonster.com
  • Start date
I

instereo911 via AccessMonster.com

Good afternoon

I have an easy question (hopefully) ~ I have a query set up and I want to
count ageddays >30 grouped by date, status, statcode -

If there are 0 aged days on the count of ageddays over >30, i want to show 0
for the groups

the code i have now is

SELECT ZZ_RoutedandMRUTotalInventory.date, ZZ_RoutedandMRUTotalInventory.
status, ZZ_RoutedandMRUTotalInventory.statcode, Count
(ZZ_RoutedandMRUTotalInventory.ageddays) AS CountOfageddays
FROM ZZ_RoutedandMRUTotalInventory
GROUP BY ZZ_RoutedandMRUTotalInventory.date, ZZ_RoutedandMRUTotalInventory.
status, ZZ_RoutedandMRUTotalInventory.statcode
HAVING (((Count(ZZ_RoutedandMRUTotalInventory.ageddays))>30 Or (Count
(ZZ_RoutedandMRUTotalInventory.ageddays))=0));

I know the = 0 is wrong.. but can someone please help me.. thank you
 
J

Jerry Whittle

See if this will work properly:

SELECT ZZ_RoutedandMRUTotalInventory.[date],
ZZ_RoutedandMRUTotalInventory.status,
ZZ_RoutedandMRUTotalInventory.statcode,
Count(ZZ_RoutedandMRUTotalInventory.ageddays) AS CountOfageddays
FROM ZZ_RoutedandMRUTotalInventory
GROUP BY ZZ_RoutedandMRUTotalInventory.[date],
ZZ_RoutedandMRUTotalInventory.status,
ZZ_RoutedandMRUTotalInventory.statcode
HAVING Count(ZZ_RoutedandMRUTotalInventory.ageddays)>30
UNION
SELECT ZZ_RoutedandMRUTotalInventory.[date],
ZZ_RoutedandMRUTotalInventory.status,
ZZ_RoutedandMRUTotalInventory.statcode,
0
FROM ZZ_RoutedandMRUTotalInventory
GROUP BY ZZ_RoutedandMRUTotalInventory.[date],
ZZ_RoutedandMRUTotalInventory.status,
ZZ_RoutedandMRUTotalInventory.statcode
HAVING Count(ZZ_RoutedandMRUTotalInventory.ageddays)<30.1 ;

Or the last line might be:

HAVING Count(ZZ_RoutedandMRUTotalInventory.ageddays) = 0
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top