Hi,
Assumed Hord is the Order No and must be unique in the order header, just
try the following:
SELECT count(Distinct HOrd)
FROM header a join detail b on hord=dord
WHERE a.xxx <> 0 and sum(b.a + b.b + b.c) <> 0
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!"
-----Ursprüngliche Nachricht-----
Von: midrange-l-bounces@xxxxxxxxxxxx
[
mailto:midrange-l-bounces@xxxxxxxxxxxx] Im Auftrag von Jim Franz
Gesendet: Monday, June 04, 2007 17:04
An: MIDRANGE-L@xxxxxxxxxxxx
Betreff: sql select count(*) and join
Just not getting it....
Need several counts between a header & detail file
1. SELECT count(*) FROM header a join detail b on hord=dord WHERE
a.xxx <> 0 and a.yyy=0
This is counting the detail records.... I need header counts.
2. SELECT count(*) FROM header a join detail b on hord=dord WHERE
a.xxx <> 0 and sum(b.a + b.b + b.c) <>0
This is counting the detail records.... I need header counts.
Appreciate any pointers. The 3 SQL books I have are useless in examples for
this. jim
As an Amazon Associate we earn from qualifying purchases.