I am doing something wrong with my join but cant figure it out. It is SQL Server 2005.
The queries:
select count(*) from tblDGHistoryPO
where ItemID = '#00 CORK'
select count(*) from tblDGHistorySO
where ItemID = '#00 CORK'
return 10 and 19 respectively. When I try to join them I get a cross join (190):
select count(*)
from tblDGHistoryPO P
inner join tblDGHistorySO S on S.ItemID = P.ItemID
where P.ItemID = '#00 CORK'
group by P.ItemID
If I remove the aggregate I get similar results (cross join with 190 rows). Anyone know what I am doing wrong?