如何查询表中每个字段的最后一个寄存器

时间:2014-09-22 18:13:30

标签: sql

我有一个包含许多客户端的许多寄存器的表I.E。:

CLIENT 1- 22/09/2014
CLIENT 1- 19/09/2014
CLIENT 1- 10/09/2014
CLIENT 2- 15/09/2014
CLIENT 2- 20/09/2014

如何查询表以便只获取每个客户端的最后一个寄存器:

CLIENT 1- 22/09/2014
CLIENT 2- 20/09/2014

2 个答案:

答案 0 :(得分:2)

select client, max(register) 
from your_table
group by client

答案 1 :(得分:0)

select client, max(register) 
from your_table
group by client, register
having max(register) = register