One to many join
id custid
1 1234
2 2345
3 3456
and 6 records in table B.
id date
1 10/01/05
2 10/01/05
2 10/03/05
3 09/30/05
3 10/01/05
3 10/02/05
The following SQL statement returns 5 records:
select a.id, a.custid from a inner join b on a.id = b.id
where b.date >= '10/01/05' and b.date <= '10/03/05'
group by a.id
Here is the return from the above query:
id custid
1 1234
2 2345
2 2345
3 3456
3 3456
I only wanted 3 records. Can someone please revise my SQL statement?
Thanks,
Dan-Yeung

