From Excel to SQL - Operators (+, -, *, /)
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: - https://www.youtube.com/playlist?list=PLEiRgvTilK5rhnVPQ_Tj3Q-CI0rGn_uiD Check out the previous video at: - https://youtu.be/Vp40VH4_OX8 ...and the next video at: - https://youtu.be/4admV4I3fMU The written version of this content is also available at: - https://billwallis.github.io/sql-learning-materials/from-excel-to-sql/main-concepts/operators/ --------------------------------------------------- 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
Download
0 formatsNo download links available.