我正在尝试执行以下代码行:
select
MIN(tr.UPC) as UPC, MIN(td.UPC) as DistUPC,
MIN(tr.ProductDescriptionReported) as ProductDescriptionReported,
MIN(td.ProductDescriptionReported) as DistProdDesc,
MIN(tr.RawProductIdentifier) as RawProductIdentifier,
MIN(td.RawProductIdentifier) as DistRawProdIden
--into #tmpCompareData
from
#tmpSTRecData tr
left join
#tmpSTDistData td on tr.ChainID = td.ChainID
and tr.StoreID = td.StoreID
and tr.SupplierID = td.SupplierID
left join
TranslationMaster tm on tr.UPC = tm.TranslationCriteria2
group by
tr.UPC
我得到了重复的结果行。
在附图中,突出显示的黄色是我得到的,输出绿色突出显示我需要。
请帮助
答案 0 :(得分:0)
试试这个:
select
tr.UPC as UPC, MIN(td.UPC) as DistUPC,
MIN(tr.ProductDescriptionReported) as ProductDescriptionReported,
MIN(td.ProductDescriptionReported) as DistProdDesc,
MIN(tr.RawProductIdentifier) as RawProductIdentifier,
MIN(td.RawProductIdentifier) as DistRawProdIden
--into #tmpCompareData
from
#tmpSTRecData tr
left join
#tmpSTDistData td on tr.ChainID = td.ChainID
and tr.StoreID = td.StoreID
and tr.SupplierID = td.SupplierID
left join
TranslationMaster tm on tr.UPC = tm.TranslationCriteria2
group by
tr.UPC