Subject RE: [ib-support] Calling all SQL Gurus...
Author Thomas Steinmaurer
Kevin,

just a thought, but can H.SALESAMT have NULL values?

Have you tried to run the query without:

HAVING
SUM ( H.SALESAMT ) <> 0

I'm not sure, but SUM (H.SALESAMT) might return NULL if
one of the H.SALESAMT values is NULL.

Regards,
Thomas Steinmaurer
IB LogManager 2.0 - The Logging/Auditing Tool for InterBase and Firebird
http://www.iblogmanager.com

> -----Original Message-----
> From: Kevin Stanton [mailto:Kevin.Stanton@...]
> Sent: Thursday, August 22, 2002 5:37 PM
> To: IB-Support
> Subject: [ib-support] Calling all SQL Gurus...
>
>
> I have a history table with two fields: yr & mo (year and month) defined as
> small ints.
>
> Possibly have a design problem here.
>
> When running a report, a user wants to select the date range from 8/1/01
> thru 7/31/2002.
>
> I've been trying various Selects but can't quite get it.
>
> The below does not select anything:
>
> SELECT
> H.CUSTNO, H.CUSTNAME,
> SUM ( H.SALESAMT ) AS SALESAMT, SUM ( H.GROSSMARGIN ) AS GROSSMARGIN
> FROM CUST_HIST H
> WHERE
> H.COMPANY = '01' AND DIVISION = '01'
> and ((H.Yr >= 2001 and H.mo >=8) and (H.Yr <= 2002 and H.mo <=7))
> GROUP BY
> H.CUSTNO, H.CUSTNAME
> HAVING
> SUM ( H.SALESAMT ) <> 0
> ORDER BY
> 3 DESC
>
> Is there a way to get this to work or do a need to create a field YYYYMM and
> append the two fields together?
>
> Thanks in advance for all ideas!
>
> Kevin
>
>
>
> To unsubscribe from this group, send an email to:
> ib-support-unsubscribe@egroups.com
>
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>
>
>