It's Autumn! Prices fall like leaves! - hours only!Up to 80% off on all courses and bundles.-Close
Reviewing SQL and numbers
So you think you can count
12. Getting rid of division by 0
Round and other functions
Review and practice

Instruction

Oops! As you can see, the error occurs even if there is a single row with a 0 value in the denominator. How can we deal with this? There are a few ways to solve the problem.

For now, you can use the good old WHERE clause to filter out those rows which contain a 0:

...
WHERE column_name != 0;

You'll get to know other methods of dealing with division by zero in further parts of our course.

Exercise

For each character, show its name and try to divide its mp by its wisdom. Filter out rows with 0 wisdom points. Name the second column ratio.

Stuck? Here's a hint!

Use:

CAST(mp AS numeric)