xwarrior
12-06-2006, 02:48 AM
how can this statement be change from a MySql query to sql server 2005 query?
SELECT
DISTINCT
TagID,
x,
y
from RTLOC
where TDate =
(SELECT max(my.TDate) from RTLOC as my
and TagID = my.TagID)
i have 4 fields, TagID, x,y,Tdate.
tag1, 123,523, date
tag1, 123, 123, latest date
tag2, 434,423, latest date
tag2, 123,432, date
tag3,342, 543,date
tag3,532,342,latest date
in the TagID field i have different names. i want to use a query statement to draw the x and Y of each different TagID by the latest TDate.
expected result should be TagID , x , y , TDate
tag1 ,123 ,123 ,latest date
tag2 ,434 ,423 ,latest date
tag3 ,532, 342 , latest date
SELECT
DISTINCT
TagID,
x,
y
from RTLOC
where TDate =
(SELECT max(my.TDate) from RTLOC as my
and TagID = my.TagID)
i have 4 fields, TagID, x,y,Tdate.
tag1, 123,523, date
tag1, 123, 123, latest date
tag2, 434,423, latest date
tag2, 123,432, date
tag3,342, 543,date
tag3,532,342,latest date
in the TagID field i have different names. i want to use a query statement to draw the x and Y of each different TagID by the latest TDate.
expected result should be TagID , x , y , TDate
tag1 ,123 ,123 ,latest date
tag2 ,434 ,423 ,latest date
tag3 ,532, 342 , latest date