I am trying to get sum of columns at the end of the query. i Mean all the data should be up there like select * from table... and at the end of each each column there should be sum of each column.i tried this but it didn't work for me.
select total_Hours,duty_hours,overtime,salary,allowence from ( select EmployeeID as Total, SUM(total_Hours) AS total_Hours, SUM(duty_hours) AS duty_hours, SUM(overtime) as Overtime, SUM(salary) AS salary, SUM(allowence) as Allowence from EmployeeHours WHERE EmployeeID = 4 GROUP BY EmployeeID ) x union all select 'Total',SUM(total_Hours) as total_Hours, SUM(duty_hours) AS duty_hours, SUM(overtime) as Overtime, SUM(salary) AS salary, SUM(allowence) as Allowence from EmployeeHours WHERE EmployeeID = 4
and it gave me this error
Conversion failed when converting the varchar value 'Total' to data type int.
and the result is like sum of each column but i dont see values of culumns, i just see sum of coulmns.
I want something like this
ID total_hrs Duty_hrs Ovtime salary 4 10 8 2 100 4 8 8 0 80 4 12 8 4 120 Total 30 24 6 300
I tried much but i couldnt get result like this.
Please Help. THanks in advance.
This post has been edited by Mohsin01: 15 January 2013 - 07:23 AM