From Excel to SQL - Operators (+, -, *, /)

Опубликовано: 16 Май 2026
на канале: Bill Wallis
13
0

The arithmetic (mathsy) operators in SQL are just like in Excel, with one major difference: division sometimes forgets about the decimal places. We cover how to ensure you can safely keep the decimal places when you divide numbers in SQL.

The dbfiddle website can be accessed for free and without an account at:

https://dbfiddle.uk/

Make sure to use the SQL Server dialect and the AdventureWorks sample database to be able to follow along with these examples!

---------------------------------------------------

This is part of the From Excel to SQL playlist, available at:

   • From Excel to SQL  

Check out the previous video at:

   • From Excel to SQL - Data Types (CHAR, INT,...  

...and the next video at:

   • From Excel to SQL - Conditionals (IIF and ...  

The written version of this content is also available at:

https://billwallis.github.io/sql-lear...

---------------------------------------------------

CHAPTERS

00:00 dbfiddle
00:28 Operators in Excel
01:45 Operators in SQL
04:46 Fixing division with explicit CAST
07:36 Fixing division by using .0
09:20 Fixing division by using 1.0 *
11:43 Warning: don't CAST after the division
13:16 Wrap up