Skip to content
Advertisement

Return decimal value in SQL query

Example of script

,sum(BREAKS)/3600 as Breaks

but it comes back as a whole number, how can I get decimals?

Advertisement

Answer

Here are two options. First, you could force an implicit cast by introducing a decimal into the calculation:

SUM(BREAKS) / 3600.0 AS Breaks

An alternative would be to use an explicit cast to decimal:

CAST(SUM(BREAKS) / 3600 AS DECIMAL(10,2)) AS Breaks
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement