答案 0 :(得分:2)
您似乎想要每个NumId
的最高ID。您可以使用row_number()
:
select t.*
from (select t.*, row_number() over (partition by NumId order by id desc) as seqnum
from t
) t
where t.seqnum = 1;
答案 1 :(得分:0)
如果没有其他行具有相同的NumTitle但ID值更高,请使用item X0 X1 X2 X3 X4 X5 ..... X98
3791 0 0 0 0 0 1 ..... 0
112 1 0 0 0 0 0 ..... 0
返回一行:
NOT EXISTS
或者,select t1.*
from tablename t1
where not exists (select 1 from tablename t2
where t2.NumTitle = t1.NumTitle
and t2.ID > t1.ID)
版本:
JOIN