0

Respected Friends Hi

I have one table named as 'payroll' with the columns employee_id,employee_name,employee_designation,

basicpay,allowances,month,year. This table data as follwoing:


employee_id , employee_name, employee_designation, basicpay , allowances , month, year

1 , SAM , MANAGER , 5000 , 1000 , JANUARY , 2011
1 , SAM , MANAGER , 6000 , 1000 , FEBRUARY , 2011
1 , SAM , MANAGER , 6500 , 1000 , MARCH , 2011
2, GEORGE , EXECUTIVE , 3000 , 500 JANUARY, 2011
2 , GEORGE , EXECUTIVE , 3500 , 500 , FEBRUARY ,2011
2 , GEORGE , EXECUTIVE , 3500 , 500 , MARCH, 2011


How should I write the SQL Select statement to get (when some columns need SUM()) the following result(OUTPUT):


employee_id = 1
employee_name = SAM
employee_designation = MANAGER

TOTAL_basicpay = 17500
TOTAL_allowances = 3000

year = 2011

2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by BitBlt
0
select employee_id , employee_name, employee_designation, sum(basicpay) as TOTAL_basicpay , sum(allowances) as TOTAL_allowances
from payroll where year = 2011
group by   employee_id , employee_name, employee_designation
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.