Return one SQL row per product with price and latest date

前端 未结 6 1102
南旧
南旧 2021-01-24 03:35

I am not a SQL guy, I have used it in the past and rarely have an issue that cant be solved by google... however this time I need to ask the Community.

I have a database

6条回答
  •  星月不相逢
    2021-01-24 04:07

    SELECT A.ProdNo ,Price ,A.TransactionDate,PurchasedBy 
    FROM #Transactions 
    JOIN 
    (
    SELECT ProdNo,MAX(TransactionDate) TransactionDate
    FROM #Transactions 
    GROUP BY ProdNo
    )A ON A.TransactionDate = #Trans.TransactionDate  
    

提交回复
热议问题