Something pretty interesting you can do in SQL is multiply two matrices. In fact, it’s actually quite efficient if the matrices are sparse, meaning that they’re populated with many zeros. Here’s the SQL code:
SELECT A.row_number, B.column_number, SUM(A.value * B.value) FROM A,B WHERE A.column_number = B.row_number GROUP BY A.row_number, B.column_number
Each table only contains entries where the value isn’t zero, since including it would be inefficient. The two tables are joined where the column number of A and the row number of B are equal (basically this filter makes sure each element in matrix A is multiplied by the right element in matrix B). The group by statement is a little tricky, but it aggregates the terms so that you end up multiplying and summing each row in table A by each column in table B.