SQL查询重复记录

时间:2015-10-07 12:18:39

标签: android sql sqlite

我有下面的表.Oquer工作正常,但它显示完整的重复记录。我希望所有带名称的记录单次出现

GridSplitter

查询:

 <Setter Property="Height" Value="5" />

2 个答案:

答案 0 :(得分:0)

Use DISTINCT keyword

select DISTINCT t1.* from customer t1 join (select Name, max(timestamp) as 
maxstamp from customer group by Name) xx  on t1.Name = xx.Name
and t1.timestamp = xx.maxstamp;

答案 1 :(得分:0)

在SQLite 3.7.11或更高版本(Android Jelly Bean或更高版本)中,您只需将MAX()与GROUP BY一起使用:

SELECT Name, Address, City, Contact, MAX(timestamp) AS timestamp
FROM Customer
GROUP BY Name;