Archives of the TeradataForum
Message Posted: Tue, 14 Jan 2003 @ 23:19:40 GMT
I am not very clear on your requirement but a variation of the following SQL could work.
select acct_num,plan_code,plan_start_date,plan_end_dt from plan_history where plan_beg_dt <= '31-NOV-2002' and plan_end_dt <= '31-NOV-2002' /* this will give history before NOV-31 or pplan_end_dt = '9999-12-31' /* this should give the transaction opened before NOV-30 and still current */ qualify csum(1,acct_num,plan_code,plan_start_dt desc, plan_end_dt desc ) = group by acct_num,plan_code /* If you want only the latest you would use a OLAP function to qualify the latest */
|Copyright 2016 - All Rights Reserved|
|Last Modified: 28 Jun 2020|