測試數據如下
例子1:要求對NAME相同的值只取一條即可
select *
from test t
where t.rowid in (select max(rowid) from test group by name)
例子1:要求對NAME相同的值只取一條且AGE值最大
select *
from test t
where (t.name, t.age) in (select name, max(age) from test group by name)
測試數據如下
select *
from test t
where t.rowid in (select max(rowid) from test group by name)
select *
from test t
where (t.name, t.age) in (select name, max(age) from test group by name)