简体   繁体   中英

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM