2017-05-12 19 views
0

2つの列に同じ値を持つ2つの行がテーブルにあります。SQLテーブル内のデータを選択中に重複を無視する方法

どのようにして1行だけを選択できますか?

Id  IP Address  Page  Datetime    Country Region 
1506 64.233.172.146 /index.php 2017-05-12 15:02:57 India Telangana 
1507 64.233.172.146 /about.php 2017-05-12 15:02:59 India Telangana 
1508 64.233.172.146 /index.php 2017-05-12 15:03:01 India Telangana 
1506 64.233.172.146 /contact.php2017-05-12 15:05:04 India Telangana 

私はあなたが集約を使用することができ、内側には、このために参加

Id  IP Address  Page  Datetime    Country Region 
1506 64.233.172.146 /index.php 2017-05-12 15:02:57 India Telangana 
1507 64.233.172.146 /about.php 2017-05-12 15:02:59 India Telangana 
1506 64.233.172.146 /contact.php2017-05-12 15:05:04 India Telangana 
+0

残りの列によって分(同上)とグループを使用します –

+0

ほんの少し説明していただけますか –

答えて

0

としての私の出力をしたい:

select * 
from your_table t1 
join (
    select ip_address, page, min(id) as id 
    from your_table 
    group by ip_address, page 
) t2 using (ip_address, page); 
+0

ありがとう –

関連する問題