動作しているように見える次のクエリを作成しましたが、潜在的な問題を探してください。ありがとう
SELECT distinct t1.PONumber, t1.LNSKUNumber, sum(t2.pair_count) AS [Size For 050], sum(t3.pair_count) AS [Size for 055],
sum(t4.pair_count) AS [Size for 060],sum(t5.pair_count) AS [Size for 065],sum(t6.pair_count) AS [Size for 070],
sum(t7.pair_count) AS [Size for 075],sum(t8.pair_count) AS [Size for 080],sum(t9.pair_count) AS [Size for 085],
sum(t10.pair_count) AS [Size for 090],sum(t11.pair_count) AS [Size for 095],sum(t12.pair_count) AS [Size for 100],
sum(t13.pair_count) AS [Size for 110],sum(t14.pair_count) AS [Size for 120],sum(t15.pair_count) AS [Size for 130]
FROM #tmptable t1
LEFT OUTER JOIN #tmptable t2 ON t2.PONumber = t1.PONumber AND t2.LNSKUNumber=t1.LNSKUNumber AND t2.SizeDescription='050B'
LEFT OUTER JOIN #tmptable t3 ON t3.PONumber = t1.PONumber AND t3.LNSKUNumber=t1.LNSKUNumber AND t3.SizeDescription='055B'
LEFT OUTER JOIN #tmptable t4 ON t4.PONumber = t1.PONumber AND t4.LNSKUNumber=t1.LNSKUNumber AND t4.SizeDescription='060B'
LEFT OUTER JOIN #tmptable t5 ON t5.PONumber = t1.PONumber AND t5.LNSKUNumber=t1.LNSKUNumber AND t5.SizeDescription='065B'
LEFT OUTER JOIN #tmptable t6 ON t6.PONumber = t1.PONumber AND t6.LNSKUNumber=t1.LNSKUNumber AND t6.SizeDescription='070B'
LEFT OUTER JOIN #tmptable t7 ON t7.PONumber = t1.PONumber AND t7.LNSKUNumber=t1.LNSKUNumber AND t7.SizeDescription='075B'
LEFT OUTER JOIN #tmptable t8 ON t8.PONumber = t1.PONumber AND t8.LNSKUNumber=t1.LNSKUNumber AND t8.SizeDescription='080B'
LEFT OUTER JOIN #tmptable t9 ON t9.PONumber = t1.PONumber AND t9.LNSKUNumber=t1.LNSKUNumber AND t9.SizeDescription='085B'
LEFT OUTER JOIN #tmptable t10 ON t10.PONumber = t1.PONumber AND t10.LNSKUNumber=t1.LNSKUNumber AND t10.SizeDescription='090B'
LEFT OUTER JOIN #tmptable t11 ON t11.PONumber = t1.PONumber AND t11.LNSKUNumber=t1.LNSKUNumber AND t11.SizeDescription='095B'
LEFT OUTER JOIN #tmptable t12 ON t12.PONumber = t1.PONumber AND t12.LNSKUNumber=t1.LNSKUNumber AND t12.SizeDescription='100B'
LEFT OUTER JOIN #tmptable t13 ON t13.PONumber = t1.PONumber AND t13.LNSKUNumber=t1.LNSKUNumber AND t13.SizeDescription='110B'
LEFT OUTER JOIN #tmptable t14 ON t14.PONumber = t1.PONumber AND t14.LNSKUNumber=t1.LNSKUNumber AND t14.SizeDescription='120B'
LEFT OUTER JOIN #tmptable t15 ON t15.PONumber = t1.PONumber AND t15.LNSKUNumber=t1.LNSKUNumber AND t15.SizeDescription='130B'
group by t1.SizeDescription, t1.PONumber, t1.LNSKUNumber