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

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
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.