Saturday, 15 June 2013

plsql - Compare record and add entry to temp and update temp particular column value in oracle for 10000 records -



plsql - Compare record and add entry to temp and update temp particular column value in oracle for 10000 records -

i think need rephrase info: (i don't how write code this)

table name : test1

here examples give i'm looking example 1

initial table name ref start date end date 5001 klm123 01/01/2011 31/05/2012 5001 klm111 01/06/2012 31/12/2012 5001 klm112 01/01/2013 31/12/2013 5001 klm112 01/01/2014 31/12/2014

final table name ref start date end date 5001 klm123 01/01/2011 31/05/2012 5001 klm111 01/06/2012 31/12/2012 5001 klm112 01/01/2013 31/12/2014 (record 3 , 4 compressed 1 given start date , end date since name , ref remains same in period)

example 2

initial table name ref start date end date 5001 klm123 01/01/2011 31/05/2012 5001 klm111 01/06/2012 31/12/2012 5001 klm112 01/01/2013 31/12/2013 5001 klm112 01/01/2014 12/12/2014 5001 klm134 01/01/2015 30/06/2015 5001 klm133 01/07/2015 31/12/2015 5002 klm144 01/01/2013 31/12/2013 5002 klm155 01/01/2014 12/12/2014

final table name ref start date end date 5001 klm123 01/01/2011 31/05/2012 5001 klm111 01/06/2012 31/12/2012 5001 klm112 01/01/2013 31/12/2014 5001 klm134 01/01/2015 30/06/2015 5001 klm133 01/07/2015 31/12/2015 5002 klm144 01/01/2013 31/12/2013 5002 klm155 01/01/2014 12/12/2014

would have "final table" table. best , optimal way in pl/sql?

thnx

with cte (select id, name, ref, start_date, max(end_date) test1 grouping id, name, ref, start_date) select t1.id, t1.name, t1.ref, t1.start_date, t1.end_date cte t1

change insert , think asking...

i think want unique records test1 based on id, name, ref , start date. , when there isn't unique value, want max end date.

oracle plsql

No comments:

Post a Comment