Division By Zero

Kevin Feasel

2016-09-30

Syntax

Erik Darling warns us against tearing the fabric of time by dividing by zero:

There are several options for fixing this. For instance, you can use a CASE expression, or COALESCE, but I find they get a tad muddled to write after a while, especially if we’re safeguarding multiple columns from our mathematical disaster. Plus,under the covers, the functions I like to use are just case expressions anyway. Isn’t it nice that SQL Server will save you a touch of typing? I think so. What a considerate piece of software!

This is a bit of a beginner tip, but it came up while we were at DBA Days, so I figured I’d write about it in case anyone runs across it.

Read on for Erik’s favorite solution to the problem.

Related Posts

Grouping And Aggregating In SQL, R, And Python

Dejan Sarka has a few examples of aggregation in different languages, including SQL, R, and Python: The query calculates the coefficient of variation (defined as the standard deviation divided the mean) for the following groups, in the order as they are listed in the GROUPING SETS clause: Country and education – expression (g.EnglishCountryRegionName, c.EnglishEducation) Country […]

Read More

Docker Commands For DBAs

Marek Masko has some commands which will help DBAs get familiar with Docker: Stop container To stop container: docker stop <container ID> To stop all running containers: docker stop $(docker ps -a -q) Most of the commands are straightforward but it’s nice to have a reference guide.

Read More

Categories

September 2016
MTWTFSS
« Aug Oct »
 1234
567891011
12131415161718
19202122232425
2627282930