Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
DECLARE @y dateDECLARE @d dateSET @y = DATEADD(m, -12, CURRENT_TIMESTAMP)SET @d = CAST(GETDATE() AS date) SELECT SUM(hsmTotalHoursWorkedByHourlyEmp + hsmTotalHoursWorkedBySalariedEmp) AS TOTAL_HOURS_YTDFROM tbl_HealthAndSafetyMonthlyDataWHERE Convert(date,hsmReportingDate) BETWEEN @y AND @d
Returns 942084.000000How do I make it return 942,084
DonAtWork
Master Smack Fu Yak Hacker
2167 Posts
Posted - 2012-04-12 : 09:50:32
Change the format in your presentation layer. How to ask: http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspxFor ultra basic questions, follow these links.http://www.sql-tutorial.net/ http://www.firstsql.com/tutor.htm http://www.w3schools.com/sql/default.asp
chapm4
Yak Posting Veteran
58 Posts
Posted - 2012-04-12 : 10:19:57
Which seems like
SELECT ROUND(SUM(hsmTotalHoursWorkedByHourlyEmp + hsmTotalHoursWorkedBySalariedEmp),1) AS TOTAL_HOURS_YTD
Would work but it doesn't
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts
Posted - 2012-04-12 : 10:29:58
quote:Originally posted by chapm4 Which seems like
SELECT ROUND(SUM(hsmTotalHoursWorkedByHourlyEmp + hsmTotalHoursWorkedBySalariedEmp),1) AS TOTAL_HOURS_YTD
Would work but it doesn't
If you want an integer value, why are you rounding the value off to a single decimal place?Try rounding off to 0 decimal places and then casting the result to an integer data type.CODO ERGO SUM