1

How can we apply excel ceiling function with significance value in SQL server ?

=Ceiling(10,3) 

it should return 12, because 12 is roundup nearest to 3

=Ceiling(36,7) 

it should return 42, because 42 is roundup nearest to 7

More examples: https://i.stack.imgur.com/kSDYI.png

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Asfan
  • 11
  • 1

1 Answers1

2

You can use arithmetic:

select ceiling(10 * 1.0 / 3) * 3

The 1.0 is to avoid integer division. If the value is numeric or float, then it is not needed.

Here is a db<>fiddle.

Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786