Re: Need help with SQL selection statement.
From: Ken Mutchell <lbebs_at_cix.compulink.co.uk>
Date: Wed, 8 Feb 1995 17:39:21 GMT
Message-ID: <D3ozpM.3Js_at_cix.compulink.co.uk>
order by emp.surname;
Date: Wed, 8 Feb 1995 17:39:21 GMT
Message-ID: <D3ozpM.3Js_at_cix.compulink.co.uk>
Steve,
You can of course join the employees table to the payments table twice, as follows:
select pay1.employee_id, emp.surname, sum(pay1.amount)-
sum(pay2.amount) net_pay from pay_records pay1, pay_records pay2,
employee_table emp
where emp.employee_id = pay1.employee_id
and emp.employee_id = pay2.employee_id
and pay2.code = 'DEDUCTION' and pay1.code='GROSS_PAY' and pay1.pay_number between '9401' and '9424'group by pay1.employee_id, emp.surname
order by emp.surname;
Hope this helps,
Barbara Received on Wed Feb 08 1995 - 18:39:21 CET