Hello i was wondering is there a way to round up to a multiple of 5 in SQL?
For example this only rounds up to ten if i set @Order = 8 or 9 but when it's 7 or 6 it rounds down to 5, i need it to round up to 10 when it's 6 or 7.
declare @Order int
set @Order = 7
select round(cast(@Order as float)/cast(5 as float),0)*5
I need
@Order = 1,2,3,4
to round up to 5@Order = 6,7,8,9
to round up to 10@Order = 11,12,13,14
to round up to 15Use the CEILING function
SELECT CEILING(@Order / 5.0) * 5
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With