Archives of the TeradataForum
Message Posted: Wed, 14 Apr 2004 @ 11:42:07 GMT
If I understand correctly your request:
I will assume that your target col cannot be included in the "group by" clause so I would see it in two steps:
SELECT A.date_col, A.definition_col, A.target_col FROM mytable A WHERE (A.date_col, A.definition_col) in ( SELECT MAX(B.date_col), B.definition_col FROM mytable B WHERE B.definition_col in (42, 44, 55) GROUP BY B.definition_col ) ;
Don't know if it is the most efficient query but it should return one record per definition (if your PK is a combination of the definition and date cols) with the max date.
|Copyright 2016 - All Rights Reserved|
|Last Modified: 27 Dec 2016|