It is not only COUNT but all aggregate functions ignore NULL values. This
does not make any difference for SUM, but COUNT(), AVG() and MIN() can
return unexpected results.
On the other side you can play around with NULL values.
Assumed your Delivery Quantity Column is not NULL capable, so it contains
*ZERO is nothing is delivered. If you have to calculate the average delivery
quantity, you need to ignore the *ZEROS. There are multiple ways how to do
it, and one of them is to convert the *ZERO into a NULL value (with the
NULLIF function) and aggregate the rest.
Just test for the differences:
Select Avg(DelQty), Avg(NULLIF(DelQty, 0))
From YourFile;
Mit freundlichen Grüßen / Best regards
Birgitta Hauser
"Shoot for the moon, even if you miss, you'll land among the stars." (Les
Brown)
"If you think education is expensive, try ignorance." (Derek Bok)
"What is worse than training your staff and losing them? Not training them
and keeping them!"
?Train people well enough so they can leave, treat them well enough so they
don't want to.? (Richard Branson)
-----Original Message-----
From: MIDRANGE-L [mailto:midrange-l-bounces@xxxxxxxxxxxx] On Behalf Of
dlclark@xxxxxxxxxxxxxxxx
Sent: Donnerstag, 2. März 2017 21:39
To: Midrange Systems Technical Discussion <midrange-l@xxxxxxxxxxxx>
Subject: Re: SQL GROUP BY and COUNT
"MIDRANGE-L" <midrange-l-bounces@xxxxxxxxxxxx> wrote on 03/02/2017
03:36:27 PM:
It's working as advertised. Count (expression) includes only the not
null
values. If you want a record count you must use count (*).
Well, that was a simple answer. I've used both before but did not
really know the difference between those usages. Thanks for the education.
Sincerely,
Dave Clark
--
int.ext: 91078
direct: (937) 531-6378
home: (937) 751-3300
Winsupply Group Services
3110 Kettering Boulevard
Dayton, Ohio 45439 USA
(937) 294-5331
****************************************************************************
*****************
This email message and any attachments is for use only by the named
addressee(s) and may contain confidential, privileged and/or proprietary
information. If you have received this message in error, please immediately
notify the sender and delete and destroy the message and all copies. All
unauthorized direct or indirect use or disclosure of this message is
strictly prohibited. No right to confidentiality or privilege is waived or
lost by any error in transmission.
****************************************************************************
*****************
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
To post a message email: MIDRANGE-L@xxxxxxxxxxxx To subscribe, unsubscribe,
or change list options,
visit:
http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx Before posting, please take a
moment to review the archives at
http://archive.midrange.com/midrange-l.
Please contact support@xxxxxxxxxxxx for any subscription related questions.
Help support midrange.com by shopping at amazon.com with our affiliate link:
http://amzn.to/2dEadiD
As an Amazon Associate we earn from qualifying purchases.