Correct me if I'm wrong, but the only reason the matrix being sparse is mentioned is because the author stuck a bunch of 0s in the matrices... this solution should work regardless of the sparsity.
Any idea how fast this is compared to java / python ?
Sparse matrix multiplication using SQL was also a homework assignment in the latest coursera course "Introduction to Data Science" by Bill Howe