Key change column
Posted: Mon Apr 02, 2012 7:42 am
THE SOURCE IS FROM ORACLE
ID NAME st_DATE
-- -- ---
1 MA 10-FEB-2010
1 MA 11-FEB-2010
1 MA 12-FEB-2010
2 CA 1-MAR-2010
2 CA 2-MAR-2010
2 CA 3-MAR-2010
3 NE 4-APR-2010
3 NE 5-APR-2010
O/P REQUIRED
ID NAME st_DATE KEYCHANGE
-- -- --- -----
1 MA 12-FEB-2010 1
1 MA 11-FEB-2010 0
1 MA 10-FEB-2010 0
2 CA 3-MAR-2010 1
2 CA 2-MAR-2010 0
2 CA 1-MAR-2010 0
3 NE 5-APR-2010 1
3 NE 4-APR-2010 0
My key column is ID and NAME.My requirement is for a particular key which is having maximum st_DATE i need to assign one and remaining records i need to assign
0 for that id .
I have done like this sort stage with link sort based on ID and NAME with both sorting and partition and in sort stage i used key column as st_DATE with desc with
sort key mode as-sort with create Key change column=true but i did not get required output please correct me?
ID NAME st_DATE
-- -- ---
1 MA 10-FEB-2010
1 MA 11-FEB-2010
1 MA 12-FEB-2010
2 CA 1-MAR-2010
2 CA 2-MAR-2010
2 CA 3-MAR-2010
3 NE 4-APR-2010
3 NE 5-APR-2010
O/P REQUIRED
ID NAME st_DATE KEYCHANGE
-- -- --- -----
1 MA 12-FEB-2010 1
1 MA 11-FEB-2010 0
1 MA 10-FEB-2010 0
2 CA 3-MAR-2010 1
2 CA 2-MAR-2010 0
2 CA 1-MAR-2010 0
3 NE 5-APR-2010 1
3 NE 4-APR-2010 0
My key column is ID and NAME.My requirement is for a particular key which is having maximum st_DATE i need to assign one and remaining records i need to assign
0 for that id .
I have done like this sort stage with link sort based on ID and NAME with both sorting and partition and in sort stage i used key column as st_DATE with desc with
sort key mode as-sort with create Key change column=true but i did not get required output please correct me?