View Full Version : Need zero to show in query results


aldeb
09-22-2008, 04:58 AM
Below is my code that gives me an average number of gauges
calibrated by day by date range. If the answer is 0 for
the date range selected how can I get 0 to show in the
query?




SELECT GagesTotalByDateRange.Gages/UniqueDatetotals.[CountofDate Due] AS [Total Gages Avg]
FROM GagesTotalByDateRange, UniqueDateTotals;

MSAccessRookie
09-22-2008, 05:15 AM
Below is my code that gives me an average number of gauges
calibrated by day by date range. If the answer is 0 for
the date range selected how can I get 0 to show in the
query?



SELECT GagesTotalByDateRange.Gages/UniqueDatetotals.[CountofDate Due] AS [Total Gages Avg]
FROM GagesTotalByDateRange, UniqueDateTotals;


I assume you want to avoid the error caused by division by zero. Try the following Statement instead


Select IIf((UniqueDatetotals.[CountofDate Due]=0), 0,
GagesTotalByDateRange.Gages/UniqueDatetotals.[CountofDate Due])
AS [Total Gages Avg]
FROM GagesTotalByDateRange, UniqueDateTotals;

aldeb
09-22-2008, 05:45 AM
Thanks for the help. That worked great!