当我为采购订单运行报表时,报表会重复产品代码的记录。
例如采购订单是:P000976,报表显示产品代码两次,而它应该只出现一次。45-5540 出现两次。
P000976 09-17-2012 15,040.00 15,040.00 0.00
45-5540 “Lordotic Cervical Spacer 10mm Lordotic Cervical Spacer 10mm” 20 20 0
45-5540 “Lordotic Cervical Spacer 10mm Lordotic Cervical Spacer 10mm” 20 20 0
当我将报告的 SQL 放入 SQL Server 并通过查看代码导致附加产品代码的位置来运行 sql 时,它是 SQL 中的这一行:
在 q.distpartno = p.distpartno 上加入 all_product_codes_VW p
select q.specialrequirement
, q.distpartno
, q.toproduce
, q.prodbegindate
, q.distributor
, rc.report_category_name
, s.productperpo
, r.ebi_released
, w.ebi_in_WIP
, p.distproductname
, tp.typeprefixdetail
, tp.cost
, '1' as ReportTotals
from all_required_vw q
left join all_shipped_grafts_new_VW s on (q.distpartno = s.distpartno and q.specialrequirement = s.ponumber)
left join all_released_Grafts_VW r on q.distpartno = r.distpartno
left join all_in_WIP_VW w on q.distpartno = w.distpartno
join all_product_codes_VW p on q.distpartno = p.distpartno
join setup_tissue_prefix tp on q.typenumber = tp.typeprefix
join setup_report_category_1 rc on q.distributor = rc.report_category_id
where q.prodbegindate < @enddate
and q.completed = '0'
and rc.report_category_name like '%' + isnull(@tcustomer, '') + '%'
order by q.prodbegindate, p.distproductname
这是连接为其创建副本的视图的 SQL。
SELECT COUNT_BIG(*) AS BIG, DistPartNo, DistProductName, Distributor, UMTBProductCode
FROM dbo.Setup_Distributor_Product_info
WHERE (Distributor <> '7') OR (Distributor IS NULL)
GROUP BY DistPartNo, DistProductName, Distributor, USSAProductCode