Quantcast
Channel: total calulation and and total expenses
Viewing all articles
Browse latest Browse all 4

total calulation and and total expenses

$
0
0

Hi,

In my  query  im able to get the total hours of every week  and total of  expenses but  im stuck with  total hours  and total of expenses

  SELECT DISTINCT e.EmpID, e.EmpName, e.StartDate, e.EndDate, e.Total,  ee.WeeklyComTotalExpenses FROM    EMPArgentTimesheet AS e LEFT OUTER JOIN (SELECT   CExpID, WeeklyComTotalExpenses FROM 
  CompanyArgentExpenses GROUP BY CExpID, WeeklyComTotalExpenses) AS ee ON ee.CExpID = e.EmpID 
 where e.EmpName LIKE 'Eberhard Neumann' AND   e.StartDate >'8/1/2015'  and e.EndDate<='8/31/2015' 


output
EmpID   EmpName                 StartDate                  EndDate               Total  WeeklyComTotalExpenses 
382	Eberhard Neumann	2015-08-02 00:00:00.000	2015-08-08 00:00:00.000	15:0:0	81.99
387	Eberhard Neumann	2015-08-09 00:00:00.000	2015-08-15 00:00:00.000	20:0:0	78.00
393	Eberhard Neumann	2015-08-16 00:00:00.000	2015-08-22 00:00:00.000	18:0:0	NULL
397	Eberhard Neumann	2015-08-23 00:00:00.000	2015-08-29 00:00:00.000	20:0:0	19.20
                                                        total                   73:00:00    179.19 //want to display  at bottom 
                      

when try with below query  IT IS NOT SHOWING CORRECT OUTPUT

WITH 
    CTE_Sum AS (SELECT        e.EmpName,  DATEADD(ms, SUM(DATEDIFF(ms, '00:00:00.000', e.Total)), '00:00:00.000') AS TotTime,ee.WeeklyComTotalExpenses
                                            FROM            EMPArgentTimesheet AS e LEFT OUTER JOIN (SELECT   CExpID, WeeklyComTotalExpenses FROM 
  CompanyArgentExpenses GROUP BY CExpID, WeeklyComTotalExpenses) AS ee ON ee.CExpID = e.EmpID 
                                            WHERE        (e.EmpName  ='Eberhard Neumann' ) AND (e.StartDate >= '8/1/2015') AND (e.EndDate <= '8/31/2015')
                                            GROUP BY e.EmpName,ee.WeeklyComTotalExpenses WITH ROLLUP
                                            HAVING GROUPING(e.EmpName) = 0)

    SELECT       'Eberhard Neumann', '8/1/2015', 
                             '8/31/2015', CAST(DATEDIFF(DAY, 0, TotTime) * 24 + DATEPART(HOUR, TotTime) 
                              AS varchar(4)) + ':' + RIGHT('00' + CAST(DATEPART(MINUTE, TotTime) AS varchar(2)), 2) + ':' + RIGHT('00' + CAST(DATEPART(SECOND, TotTime) AS varchar(2)), 2) 
                              AS TotalHours,WeeklyComTotalExpenses
     FROM            CTE_Sum AS CTE_Sum_1
Name                    StartDate        EndDATE         hOURS        wEEKLYcOMANYeXPENSES 
Eberhard Neumann	8/1/2015	8/31/2015	90:00:00	NULL
Eberhard Neumann	8/1/2015	8/31/2015	100:00:00	19.20
Eberhard Neumann	8/1/2015	8/31/2015	100:00:00	78.00
Eberhard Neumann	8/1/2015	8/31/2015	75:00:00	81.99
Eberhard Neumann	8/1/2015	8/31/2015	365:00:00	NULL




Viewing all articles
Browse latest Browse all 4

Latest Images

Trending Articles





Latest Images