Use SAFE_DIVIDE to handle division by zero.


π™Žπ˜Όπ™π™€_π˜Ώπ™„π™‘π™„π˜Ώπ™€ divides two numbers while handling the case where the denominator is zero.

πŸ“Œ Here's the syntax.
πš‚π™΄π™»π™΄π™²πšƒ πš‚π™°π™΅π™΄_π™³π™Έπš…π™Έπ™³π™΄(πš—πšžπš–πšŽπš›πšŠπšπš˜πš›, πšπšŽπš—πš˜πš–πš’πš—πšŠπšπš˜πš›) π™΅πšπ™Ύπ™Ό πš—πšžπš–πš‹πšŽπš›πšœ

If the denominator is zero for any row, it returns NULL instead of causing your query to fail.

π™Žπ˜Όπ™π™€_π˜Ώπ™„π™‘π™„π˜Ώπ™€ is not part of the standard SQL language, but it is often included as a custom function.

If your SQL database does not include the SAFE_DIVIDE function, you can use the CASE statement to handle division by zero. Example below!

More from Travis Tang
Use ARRAY_AGG to flatten columns to lists.

Use ARRAY_AGG to flatten columns to lists.

You need to convert a long table of values into a list? This is the most convenient function. πŸ“Œ Syntax: πš‚π™΄π™»π™΄π™²πšƒ π™°πšπšπ™°πšˆ_𝙰𝙢𝙢(πšŒπš˜πš•πšžπš–πš—) π™΅πšπ™Ύπ™Ό πšπšŠπš‹πš•πšŽ There
Pivot Table (From Long to Wide)

Pivot Table (From Long to Wide)

Every data scientist, scientist, and engineer should know how to create a pivot table. π™²π™°πš‚π™΄ πš†π™·π™΄π™½ is the best way to do
Great! You’ve successfully signed up.
Welcome back! You've successfully signed in.
You've successfully subscribed to Travis Tang.
Your link has expired.
Success! Check your email for magic link to sign-in.
Success! Your billing info has been updated.
Your billing was not updated.