UPDATE a
SET CountOfAA=dt.CountOf
FROM @MediaResurce a
INNER JOIN (SELECT
aa.Sku,ISNULL(COUNT(bb.sku),0) AS CountOf
FROM @MediaResurce aa
LEFT OUTER JOIN @MediaResurce_Pics bb
ON aa.sku=bb.sku
WHERE somecol = 0
GROUP BY aa.Sku
) dt ON a.sku=dt.sku
/////////////SQL:我怎麼能把它變成一個查詢?
UPDATE a
SET CountOfBB=dt.CountOf
FROM @MediaResurce a
INNER JOIN (SELECT
aa.Sku,ISNULL(COUNT(bb.sku),0) AS CountOf
FROM @MediaResurce aa
LEFT OUTER JOIN @MediaResurce_Pics bb
ON aa.sku=bb.sku
WHERE somecol = 1
GROUP BY aa.Sku
) dt ON a.sku=dt.sku
哦SQL Server,我多麼喜歡你的奇怪語法。 – vol7ron 2010-10-15 22:37:59
哦上帝請有人幫助我這是給我一個恐慌發作 – wil 2010-10-15 23:05:29