I am trying to work this solution on how to collapse the records based on a value..
Table 1(Input)
Emp_ID Start_Date End_Date Rating Department Salary
2000 01012011 12312011 A HR 10000
2000 01012012 12319999 A HR 20000
3000 01012011 12312011 B Operations 50000
3000 01012012 12312012 B Operations 60000
3000 01012013 12319999 C Operations 70000
Table 2(Output)
Emp_ID Start_Date End_Date Rating Department
2000 01012011 12319999 A HR
3000 01012011 12312012 B Operations
3000 01012013 12319999 C Operations
Database is oracle. I just need some start on how to solve this problem so that i can work on it..
Thanks in Advance..
EDIT: Assuming that Table 1 & Table 2 has EMP_NAME column. But i am not able to load this column in table2 as group by wont let me do that..(I am talking abt the soln given by Pablo Santa Cruz)
Any solutions on this..
EDIT: Edited the table structure agan..sorry for confusion
Try this:
If you need to actually store the values on
table_2table, start the previous SQL statement withcreate table table_2 as.Considering what you’ve comment, you can do:
Other possibility might be creating the table first, and then doing an
alter tableto include the new column.