sql - Selecting one row from multiple similar ones based on most recent date -
i have table structured this:
customer_name, datea, dateb, datec
datea<=dateb<=datec.
customers listed multiple times different dates each datea, dateb, , datec.
so if info looks like:
x, 10/01, 10/02, 10/03 x, 10/04, 10/05, 10/06 x, 10/05, 10/07, 10/08 y, 10/01, 10/05, null y, 10/01, 10/06, null z, 10/02, null, null z, 10/03, 10/04, null
i want:
x, 10/05, 10/07, 10/08 y, 10/01, 10/06, null z, 10/03, 10/04, null
in other words want 1 row per client furthest along in process datea, dateb, , datec milestones in process.
if 2 rows same client , @ same milestone, i'd select 1 furthest date.
i'm using teradata 14.10.
fairly new sql help appreciated.
this homecoming expected result:
select * tab qualify row_number() on (partition customer_name order datec desc, dateb desc, datea desc) = 1
sql duplicates teradata
No comments:
Post a Comment