簡體   English   中英

使用兩列的組合從表中獲取不同的行

[英]Getting distinct rows from a table using combination of two columns

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列”和“ Title列”的不同值。 例如,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

非常感謝。

select * from table where id in (select min(id) from table group by handle, title)   

要么

select * from table where id in (select max(id) from table group by handle, title)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM