469,600 Members | 2,393 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,600 developers. It's quick & easy.

I would like to simplify my query

What I'm trying to do is get the last entry (by date) for a given entity (which should be a single row). The following returned more than one row:

select termId, entityId, max(enddate)
from Terms
where entityId = 1234
group by termId, entityId

This does return me one row:

select *
from Terms
where enddate in (select max(enddate)
from Terms
where entityId = 1234)

What I would like to do this in one select statement. Does anyone have any suggestions?
Jul 13 '07 #1
1 899
hariharanmca
1,977 1GB
What I'm trying to do is get the last entry (by date) for a given entity (which should be a single row). The following returned more than one row:

select termId, entityId, max(enddate)
from Terms
where entityId = 1234
group by termId, entityId

This does return me one row:

select *
from Terms
where enddate in (select max(enddate)
from Terms
where entityId = 1234)

What I would like to do this in one select statement. Does anyone have any suggestions?

I think your query is correct. I canít get what you mean for simplify my query?

If you want you have to explain your requirement
Jul 14 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

303 posts views Thread by mike420 | last post: by
22 posts views Thread by Alan | last post: by
6 posts views Thread by pragile | last post: by
3 posts views Thread by Bob Bedford | last post: by
6 posts views Thread by Patrick | last post: by
AmLegacy
1 post views Thread by AmLegacy | last post: by
3 posts views Thread by Hvid Hat | last post: by
5 posts views Thread by Jon Skeet [C# MVP] | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.