atrices are very useful mathematical objects that science and technology professionals use to describe real-life scenarios and build abstract models for those scenarios. You will find matrices used in economics and statistics, in cryptography and genetics, and in computer graphics. Unfortunately for database developers, SQL and SQL Server do not support direct operations on matrices. However, because tables and matrices share the same structures, SQL allows easy manipulations with matrices. This article demonstrates a few SQL techniques for performing some basic operations on matrices.

**Some Matrix Operation Definitions**

A matrix is a rectangular array of elements, where the elements can be symbols, symbolic expressions, or numbers (see Figure 1 below):

**Figure 1. Matrix Representation**: A matrix is a rectangular array of elements, which can be symbols, symbolic expressions, or numbers. |

In general, matrix **A** in Figure 1 can be denoted by the following:

In this denotation, **m** is the number of rows and **n** is the number of columns in the matrix **A**. Notation **m x n** represents the size of the matrix, so matrix **A** can also be denoted by **A**_{m x n} or by **[A]**_{m x n}.

The first matrix in Figure 1 has three rows and four columns. Therefore, the size of that matrix is 3 x 4. The size of the second matrix in Figure 1 is 3 x 3. This matrix is also called a square matrix, because the number of rows is equal to the number of columns.

Each element of the matrix **A**_{m x n} is denoted by **a**_{ij}, where the row number is **1 ≤ i ≤ m** and the column number is **1 ≤ j ≤ n**. The element **a**_{23} of the first matrix is located in the third column of the second row. Similarly, you can find the location of element **a**_{23} in the second matrix. The value of that element is **a**_{23} = 20.