On 30-Dec-2015 10:08 -0700, Hoteltravelfundotcom wrote:
I am just checking against the order file.
I am getting something like 12000 for a count and I kind of doubt
that for one day of orders. I need to show how many orders we shipped
for the year eventually.

SELECT DISTINCT count(*) ihorno
FROM CA1665AFCV/SROISH T01
WHERE IHIDAT >= 20151229

As for the "one day", the predicate probably should be coded as an equal, rather than a greater-than-or-equal.

Given the result of a COUNT aggregate is a scalar value, the DISTINCT in that SELECT is effectively redundant; that request for DISTINCT processing can be ignored by the query engine, because the request is meaningless, as coded.

If the intention is to obtain a count of the non-NULL distinct values of the ORDER_NBR column, for the IHIDAT date of 2015-12-29, then the following query may be intended:

SELECT count(DISTINCT ORDER_NBR) AS ihorno
FROM CA1665AFCV/SROISH T01
WHERE IHIDAT = 20151229

As for the /distinct/, I would expect the file likely would have a unique key, likely a primary key constraint, that prevents duplicates; i.e. the DISTINCT would be similarly redundant in the above query as well as was noted for the query in the OP.


This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2019 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].