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.
Author |
Topic |
tlug
Starting Member
21 Posts |
Posted - 2012-02-24 : 13:20:49
|
Hello,I am working on a query that I need some help with.. I know it is likely something really simple that I have overlooked and just can't get it the way I want it..Below is the data that the query is spitting out.. All I want is for it to Sum for each employee for the entire week, where as right now it shows to total for each day.So for Janice Acosta it would read:ACOSTA, JANICE 8900 8/5/11 REG 39:30:00So I want it to total by Paycode for each employee.ACOSTA, JANICE 8900 8/2/11 REG 7:59 AMACOSTA, JANICE 8900 8/3/11 REG 7:57 AMACOSTA, JANICE 8900 8/1/11 REG 7:53 AMACOSTA, JANICE 8900 8/5/11 REG 7:53 AMACOSTA, JANICE 8900 8/4/11 REG 7:48 AMADAM-ROSS, RACHAL F. 8450 8/5/11 OT15 12:44 AMADAM-ROSS, RACHAL F. 8450 8/3/11 REG 8:05 AMADAM-ROSS, RACHAL F. 8450 8/2/11 REG 8:05 AMADAM-ROSS, RACHAL F. 8450 8/4/11 REG 8:03 AMADAM-ROSS, RACHAL F. 8450 8/5/11 REG 7:19 AMADAM-ROSS, RACHAL F. 8450 8/1/11 REG 8:28 AMADAME, GRICELLE 20211 8/2/11 REG 8:04 AMADAME, GRICELLE 20211 8/1/11 REG 8:03 AMADAME, GRICELLE 20211 8/4/11 REG 8:12 AMADAME, GRICELLE 20211 8/3/11 REG 4:10 AMADAME, GRICELLE 20211 8/5/11 REG 6:15 AMADAME, GRICELLE 20211 8/3/11 VCHR 4:00 AMSelect Pay.[PERSONFULLNAME],Pay.[PERSONNUM] as EmployeeID,Pay.[applydate] as Week_Ending,Pay.[PAYCODENAME]as Hours_Type,CAST(Sum(CAST(Pay.TIMEINSECONDS AS FLOAT) /86400 ) AS FLOAT) AS timeInXLSfROM [tkcsdb].[dbo].[VP_TOTALS]as Pay (NOLOCK)Where applydate between '2011-07-31' and '2011-08-06'and [LABORLEVELNAME2] = 'AUSTIN10380' AND (Pay.PAYCODENAME NOT LIKE 'PCR%') AND (Pay.PAYCODENAME NOT LIKE 'U%') AND (Pay.PAYCODETYPE = 'P') Group ByPay.[PERSONFULLNAME],Pay.[PERSONNUM],Pay.[applydate],Pay.[PAYCODENAME]Order ByPay.[PERSONFULLNAME],Pay.[PAYCODENAME] Thanks! |
|
X002548
Not Just a Number
15586 Posts |
|
tlug
Starting Member
21 Posts |
Posted - 2012-02-24 : 14:58:34
|
Everything is Text except for the last column... The timeinseconds is an integer.Thanks! |
|
|
tlug
Starting Member
21 Posts |
Posted - 2012-02-24 : 15:01:14
|
Actually sorry, obviously the date column is a date, the rest is all text except for the timeinseconds field which is an integer.Thanks! |
|
|
tlug
Starting Member
21 Posts |
Posted - 2012-02-24 : 15:49:32
|
I don't know how to create a DLL in SSMS.. But I am querying the data from a view..[PERSONFULLNAME] is a varchar(64)[PERSONNUM] is a varchar(15)[applydate] is a datetime[PAYCODENAME] is a varchar(50)TIMEINSECONDS is an intIm simply trying to total the number of hours for each employee.. So the query right now shows the total number of hours for each day, and I want the total number of hours..I can't seem to figure out how to get to that next step where it just outputs the total hours instead of the hours for each day.Thanks! |
|
|
X002548
Not Just a Number
15586 Posts |
|
tlug
Starting Member
21 Posts |
Posted - 2012-02-24 : 16:31:31
|
I figured out another way to do it.. But im still interested to see if there was another way to do it..Im determining the hours by dividing the number of seconds by 86400 which puts the seconds into a decimal form and then you can just change the format to hours in Excel.The reporting is for a week, and for each employee.Thanks! |
|
|
|
|
|
|
|