0

I am using SQL Server 2012.

I have the following operation:

select 1/12

Why does it result in zero?

I expect 0.08333333

Regards.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
  • Possible duplicate of [Decimal values in SQL for dividing results](http://stackoverflow.com/questions/4834973/decimal-values-in-sql-for-dividing-results) – Steve Lovell Apr 17 '17 at 19:55
  • Possible duplicate of [Integer division in sql server](http://stackoverflow.com/questions/3443672/integer-division-in-sql-server) – S3S Apr 17 '17 at 19:56

1 Answers1

2

You're implicitly asking for an integer result, because both "1" and "12" are integers. All you have to do is to change one (or both) of them to a decimal to get what you want.

SELECT 1.0/12
John Pasquet
  • 1,824
  • 15
  • 20