[英]Filter rows based on condition sql server 2008
以下是示例數據。
Op_ID manual TT ------------------ 1 0 32 1 1 38.4 2 0 4.56 2 1 7.5 55 1 50 55 1 30
So i need the output like below.
Op_ID manual TT ------------------ 1 0 32 2 0 4.56 55 1 50
select opid, manual, tt
from (
select *, row_number() over (partition by opid order by manual, tt desc) rn
from yourtable ) v
where rn = 1
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.