Return one SQL row per product with price and latest date

前端 未结 6 1199
南旧
南旧 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:09

    Pls Try this --If one ProdNo has two same max TransactionDate, will return both two rows

    select ProdNo,Price,TransactionDate from Transactions t 
    where not exists (select 1 from Transactions where ProdNo=t.ProdNo and TransactionDate>t.TransactionDate)
    

提交回复
热议问题