waqas
02-12-2012, 09:15 AM
Dear Experts,
i have below query to calculate OFF, Sick Leave, Annual Leave .... etc
these all information in one column against each id and date.
now i want to calculate all in different columns each inforamation in seprate column to do this i am using below query. but it becomes very slow
and when i scroll down it starts calculation again. any other solution to calculation.:cool:
SELECT TblTimeSheetTest.IDNUM, Format([SDay],"mmm") AS Mnth, Sum(TblTimeSheetTest.NHrs) AS SumOfNHrs, Sum(TblTimeSheetTest.OTHrs) AS SumOfOTHrs, Sum(TblTimeSheetTest.PreHrs) AS SumOfPreHrs, Sum(TblTimeSheetTest.TotalHrs) AS SumOfTotalHrs,
(SELECT count(offalias.tanda) from tbltimesheettest as offalias where offalias.tanda = "OFF" and offalias.idnum = tbltimesheettest.idnum) AS OFF,
(SELECT count(offalias.tanda) from tbltimesheettest as offalias where offalias.tanda = "Sick Leave" and offalias.idnum = tbltimesheettest.idnum) AS SL,
(SELECT count(offalias.tanda) from tbltimesheettest as offalias where offalias.tanda = "Annual Leave" and offalias.idnum = tbltimesheettest.idnum) AS AL
FROM TblTimeSheetTest
GROUP BY TblTimeSheetTest.IDNUM, Format([SDay],"mmm");
i have below query to calculate OFF, Sick Leave, Annual Leave .... etc
these all information in one column against each id and date.
now i want to calculate all in different columns each inforamation in seprate column to do this i am using below query. but it becomes very slow
and when i scroll down it starts calculation again. any other solution to calculation.:cool:
SELECT TblTimeSheetTest.IDNUM, Format([SDay],"mmm") AS Mnth, Sum(TblTimeSheetTest.NHrs) AS SumOfNHrs, Sum(TblTimeSheetTest.OTHrs) AS SumOfOTHrs, Sum(TblTimeSheetTest.PreHrs) AS SumOfPreHrs, Sum(TblTimeSheetTest.TotalHrs) AS SumOfTotalHrs,
(SELECT count(offalias.tanda) from tbltimesheettest as offalias where offalias.tanda = "OFF" and offalias.idnum = tbltimesheettest.idnum) AS OFF,
(SELECT count(offalias.tanda) from tbltimesheettest as offalias where offalias.tanda = "Sick Leave" and offalias.idnum = tbltimesheettest.idnum) AS SL,
(SELECT count(offalias.tanda) from tbltimesheettest as offalias where offalias.tanda = "Annual Leave" and offalias.idnum = tbltimesheettest.idnum) AS AL
FROM TblTimeSheetTest
GROUP BY TblTimeSheetTest.IDNUM, Format([SDay],"mmm");