我對SQL很陌生,這是我第一次嘗試編寫查詢。SQL選擇重複結果問題
我已經成功地將我需要的數據與下面的數據相提並論,但是由於每個項目有多個useddates
我的結果顯示每個項目有多個實例。我試過用MAX確認我是否正確。
預期結果:每個項目只能看到一條最新的lastuseddate
。
use bosext
SELECT artno, shorttext, longtext, price,MAX(lastuseddate) as LastUsed
FROM accountitem, accountitemdyn
WHERE NOT EXISTS
(SELECT *
FROM shelfitem
WHERE accountitem.ID = shelfitem.itemID)
Group by accountitem.artno,shorttext, longtext, price, lastuseddate
後所有表樣本數據 – Matt
勉力讓它與以下指導一起工作:)謝謝 – S3renity