Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 total

Author  Topic 

kshitizgp
Starting Member

31 Posts

Posted - 2012-02-02 : 08:39:05

select work_date , sum(work_hours)as hours FROM dbo.Form_Details group by work_date ,employee_id
Having Work_Date BETWEEN '2012-01-01' and '2012-01-02' and employee_id = 1
Union
select isnull(convert(VARCHAR,work_date),'GRAND TOTAL') AS work_date ,sum(hours) from dbo.Form_Details
group by work_date ,employee_id
Having Work_Date BETWEEN '2012-01-01' and '2012-01-02' and employee_id = 1

this query is not wrking am not getting the total please guide mee

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-02-02 : 10:05:47
just use

select work_date , sum(work_hours)as hours FROM dbo.Form_Details group by work_date ,employee_id
Having Work_Date BETWEEN '2012-01-01' and '2012-01-02' and employee_id = 1
WITH ROLLUP



------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -