June 14, 2012
Dominic Delmolino put together a very interesting challenge. The challenge is to produce something called a Pascal matrix using Oracle Database… more specifically, just SQL. I had a vague recollection of Pascal matrixes when I read Dominic’s challenge. Basically, the goal is to create a matrix similar to the following:
The rule for generating the matrix is simply that a cell’s value is the sum of the value in the cell that is immediately to the left plus the value in the cell that is immediately above. Sounds easy, right?
If we were just working in Microsoft Excel (or some other spreadsheet package), we could do something like this to quickly create the matrix:
Dominic’s challenge probably would not be much of a challenge if we could just type in formulas like the above into a SQL statement. Give his challenge a try to see if you are able to derive a unique solution to the problem. I probably spent a couple of minutes (maybe 60 seconds with the help of copy and paste) creating the above example using Microsoft Excel, but spent a couple of hours trying to produce a solution that worked using SQL.
Part 2 of the challenge.
Take a look at the bullet point items in this blog article about NULL values in table’s columns, in particular the first three large bullet point items. Do you agree or disagree with the statements, and why?