我有一个表,TEmployee,其中SequenceId,Date,EmplId,ExtnNumber,FName是属性,其中SequenceId是唯一的,并且将有多个条目用于相同的EmplId,如
1 1/1/2014 55323 8793 Ryan
2 1/2/2014 83723 9898 Roy
3 1/1/2014 88838 8823 Mark
4 1/2/2014 83723 9832 Roy
5 1/3/2014 32323 2223 Tina
6 1/1/2014 55323 8744 Ryan
select * from TEmployee where EmplId in ('55323','83723')
请将以下网址列入我的内容..
1 1/1/2014 55323 8793 Ryan
2 1/2/2014 83723 9898 Roy
4 1/2/2014 83723 9832 Roy
6 1/1/2014 55323 8744 Ryan
但是,我想列出要显示的最新条目..最新的意思是SequenceId ..只有条目4& 6 ..
任何指针都会有很好的帮助。在此先感谢。
答案 0 :(得分:0)
一种方法可以通过子查询,
select * from TEmployee where EmplId in ('55323', '83723') and SequenceId in (Select Max(SequenceId) where EmplId in ('55323', '83723'))
答案 1 :(得分:0)
EMPLID IN ('55323', '83723')
部分。
SELECT *
FROM TEMPLOYEE AS A
WHERE EMPLID IN ('55323', '83723')
AND SEQUENCEID = (
SELECT MAX(SEQUENCEID)
FROM TEMPLOYEE AS B
WHERE A.EMPLID = B.EMPLID
)
WITH UR