item_id emp_id entry_date description initial_amount other
1 1090554 09/27/04 MA STARTED
2 1090554 09/29/04 MA COMPLETED 5000.00 55000
34 2388601 04/15/02 MA STARTED
35 2388601 04/24/02 MA COMPLETED 22000.00 122000
36 2388601 10/09/02 MA STARTED
37 2388601 10/16/02 MA COMPLETED 39000.00 139000
38 2388601 04/08/03 MA STARTED
39 2388601 04/11/03 MA COMPLETED 50000.00 150000
40 2388601 10/08/03 MA STARTED
41 2388601 10/08/03 MA STARTED
42 2388601 10/15/03 MA COMPLETED 63000.00 163000
43 2388601 04/19/04 MA STARTED
44 2388601 04/23/04 MA COMPLETED 63000.00 163000
45 2388601 10/04/04 MA STARTED
46 2388601 10/06/04 MA COMPLETED 66000.00 166000
Here I need to write a query where I need to combine this different columns to a single row
of the table tbl_emp_category with the columns
emp_id ordered_date receieved_date amount advances
Here the conditions are as follows:-
If the description is 'MA STARTED' then get the entry_date as ordered_date in the table tbl_emp_category
IF the description is 'MA COMPLETED then get the entry_date as receieved_date in the table tbl_emp_category
and the intial_amount will be the amount and the other will be the advances in the table tbl_emp_category
one more thing we need take care is the multiple emp_ids.In that case we need to get the pair with the one with max entry_date.
please help me with the query
1 1090554 09/27/04 MA STARTED
2 1090554 09/29/04 MA COMPLETED 5000.00 55000
34 2388601 04/15/02 MA STARTED
35 2388601 04/24/02 MA COMPLETED 22000.00 122000
36 2388601 10/09/02 MA STARTED
37 2388601 10/16/02 MA COMPLETED 39000.00 139000
38 2388601 04/08/03 MA STARTED
39 2388601 04/11/03 MA COMPLETED 50000.00 150000
40 2388601 10/08/03 MA STARTED
41 2388601 10/08/03 MA STARTED
42 2388601 10/15/03 MA COMPLETED 63000.00 163000
43 2388601 04/19/04 MA STARTED
44 2388601 04/23/04 MA COMPLETED 63000.00 163000
45 2388601 10/04/04 MA STARTED
46 2388601 10/06/04 MA COMPLETED 66000.00 166000
Here I need to write a query where I need to combine this different columns to a single row
of the table tbl_emp_category with the columns
emp_id ordered_date receieved_date amount advances
Here the conditions are as follows:-
If the description is 'MA STARTED' then get the entry_date as ordered_date in the table tbl_emp_category
IF the description is 'MA COMPLETED then get the entry_date as receieved_date in the table tbl_emp_category
and the intial_amount will be the amount and the other will be the advances in the table tbl_emp_category
one more thing we need take care is the multiple emp_ids.In that case we need to get the pair with the one with max entry_date.
please help me with the query