Monday, 23 January 2017

Round Up To Next Whole Number TSQL



Image result for round up numbers


I was looking for a way to round up the results of a query to the next whole number and after
 fair bit of searching the net and experimenting to get this to work in SQL 2005
The result was


declare @totalpallets as int
declare @total as int
declare @palletsize as int


set total_pallets =  (select ceiling(cast(@total as float)/cast(@palletsize as float)))



This does the job admirably

No comments:

Post a Comment

Chrome 138 the last supported

Chrome 138 the last supported  Hey Everyone, Chrome 138 is the last version of Chrome that will support Android 8.0 (Oreo) and Android 9.0 (...