Don't let SQL divide by zero ruin your day | Essential SQL
May 11, 2024
How to Avoid Divide by Zero
In SQL, divide by zero ruins our day. Your whole query fails, and you just want results. What to do?
Watch this video to learn two solutions to work around this issue.
One Last Thing...
This video is part of my Beginner Learning series. If you're interested in learning SQL subscribe to @Essential SQL and then check out our Intermediate Learner Playlist. Of course, I also encourage you to visit https://www.essentialsql.com to learn even more!
Important links:
Sample PizzaDB: https://github.com/kwenzel1/EssentialSQLSamples/tree/master/PizzaDB
Corresponding Article: https://www.essentialsql.com/how-to-avoid-sql-divide-by-zero/
Learn more about derrived tables here: https://www.essentialsql.com/derived-tables/
Learn more about CASE WHEN here: https://www.essentialsql.com/sql-case/
Source Code:
--How to Avoid SQL Divide by Zero
--Works with SQL Server, PostgreSQL, and MySQL
Show More Show Less #Computer Education
