Status Time Handel Title
--------- ------------ ------ -------------
CREATED 2009-10-16 03:37:38+01 902D8 Mozilla Firefox
ACTIVATED 2009-10-16 03:37:38+01 902D8 -?-
ACTIVATED 2009-10-16 03:37:41+01 902D8 -?-
ACTIVATED 2009-10-16 03:37:41+01 E030E Windows Live Messenger
DESTROYED 2009-10-16 03:37:42+01 E030E Windows Live Messenger
ACTIVATED 2009-10-16 03:37:42+01 902D8 -?-
DESTROYED 2009-10-16 03:37:53+01 902D8 -?-
我想要仅基于“handel column”和“Title column”的不同值。例如,Handel:902D8和Title: - ? - 应该只出现一次
对上述数据的查询结果应为
Status Time Handel Title
--------- ------------ ------ -------------
CREATED 2009-10-16 03:37:38+01 902D8 Mozilla Firefox
ACTIVATED 2009-10-16 03:37:38+01 902D8 -?-
ACTIVATED 2009-10-16 03:37:41+01 E030E Windows Live Messenger
非常感谢。
答案 0 :(得分:1)
select * from table where id in (select min(id) from table group by handle, title)
OR
select * from table where id in (select max(id) from table group by handle, title)