我有一个问题,我认为是与我的SQL语句中的加入有关。SQL加入问题
select s.customer as 'Customer',
s.store as 'Store',
s.item as 'Item',
d.dlvry_dt as 'Delivery',
i.item_description as 'Description',
mj.major_class_description as 'Major Description',
s.last_physical_inventory_dt as 'Last Physical Date',
s.qty_physical as 'Physical Qty',
s.avg_unit_cost as 'Unit Cost',
[qty_physical]*[avg_unit_cost] as Value
from argus.DELIVERY d
join argus.STORE_INVENTORY s
ON (s.store = d.store)
join argus.ITEM_MASTER i
ON (s.item = i.item)
join argus.MINOR_ITEM_CLASS mi
ON (i.minor_item_class = mi.minor_item_class)
join argus.MAJOR_ITEM_CLASS mj
ON (mi.major_item_class = mj.major_item_class)
where s.last_physical_inventory_dt between '6/29/2011' and '7/2/2012'
and s.customer = '20001'
and s.last_physical_inventory_dt IS NOT NULL
它回来看似无限量的一个记录的副本。我加入这些表的方式有什么问题吗?
而不是你正在查看的所有列,我建议选择'COUNT(*)'来找出实际返回的记录数。 – Gabe
哇,这会返回1623697 ...但是它一遍又一遍的记录! – fullOfQuestions
尝试一次注释掉其中一个连接 – Andomar