我得到了下表内容:
> id text time
> 1 Hi 2
> 2 Hello 1
> 1 Mr. SP 3
> 3 KK 1
> 2 TT 2
> 1 Sample 1
> 1 App 4
我需要为带有文本的 id 选择不同的值,因此输出应该是:
id text time 1 App 4 2 TT 2 3 KK 1
谁能帮我解决这个问题。
我正在使用 Sqlite
谢谢
最佳答案
select b.*
from
(
select id, max(time) as time
from yourtable
group by id) a inner join yourtable b on a.time = b.time and a.id = b.id
关于mysql - 为不同的 id sqlite 选择前 1 行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22576392/