March 13, 2009 at 3:44 am
Hi people.......
HELP ME PLEASE !!!!!!!
I have a table with 5 fields with this value
FIELD A FIELD B FIELD C FIELD D FIELD E
200310D1803040650990 031 D 180304065099077,00
200310D1803041110650 031 D 180304111065091,00
20031AD1803040650990 031 D 1803040650990136,00
i want to get all the record from this table but when the field D is equal (like the firse and the second) ......i want to get only the record with the FIELD E higher...and have this result
FIELD A FIELD B FIELD C FIELD D FIELD E
200310D1803041110650 031 D 180304111065091,00
20031AD1803040650990 031 D 1803040650990136,00
Thank you in advance
Alberto
March 13, 2009 at 4:12 am
Alberto.Omini (3/13/2009)
Hi people.......HELP ME PLEASE !!!!!!!
I have a table with 5 fields with this value
FIELD A FIELD B FIELD C FIELD D FIELD E
200310D1803040650990 031 D 180304065099077,00
200310D1803041110650 031 D 180304111065091,00
20031AD1803040650990 031 D 1803040650990136,00
i want to get all the record from this table but when the field D is equal (like the firse and the second) ......i want to get only the record with the FIELD E higher...and have this result
FIELD A FIELD B FIELD C FIELD D FIELD E
200310D1803041110650 031 D 180304111065091,00
20031AD1803040650990 031 D 1803040650990136,00
Thank you in advance
Alberto
Could you provide some DDL (as explained in the link below), so I can test the code I produce? However, I made a query you may test:SELECT A.FieldA, A.FieldB, A.FieldC, A.FieldD, A.FieldE
FROM TableA A
INNER JOIN
(
SELECT FieldD, MAX(FieldE) FieldE
FROM TableA X
GROUP BY FieldD
) B ON A.FieldD = B.FieldD
WHERE A.FieldE = B.FieldE
Ronald HensbergenHelp us, help yourself... Post data so we can read and use it: http://www.sqlservercentral.com/articles/Best+Practices/61537/-------------------------------------------------------------------------2+2=5 for significant large values of 2
March 13, 2009 at 4:15 am
FANTASTIC !!!!!!!
thanks !!!!!!
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply