providing a single line for multiple records from a table
i have 3 tables as follows:
table1: empl
roll no , name, dt_birth,dt_appt,desg_code
123 , raja,01/07/1971, 01/01,1996
table2: sal_amount
roll no , year , month , code , amount
123 , 2013 , 06, 1101 , 15000
123 2013 06 6270 500
table 3 ; saldesg
de_code, de_name
I want to get a single entry for each rollno as
roll no , name, dt_of_birth ,dt_appt{from table1},de_name {from table 3}, amount in 1101 as basic, amount in 6270 as allowance {from table 2}.
I have written the query which is taking a quite long time.
select a.rollno,a.name,a.dt_birth,a.dt_appt,b.de_name,sum(case when c.code=1101 then amount else 0 end) as basic, sum(case when c.code=6270 then amount else 0 end ) as allowance from empl a,saldesg b , salamount c where a.rollno = c.rollno and a.desg_code = b.de_code ;