Previous Next JavaScript must be enabled to correctly display this content

## Computing values for new columns

The SELECT statement can contain computational expressions based on the values of existing columns. For example, in the next statement, you select the values of one column, income, divide each value by 12, and display the output in another column. The SELECT statement can use almost any type of expression. If more than one value is returned, the items are inserted into an array.

This SELECT statement uses the yearly income values divided by 12 to calculate the corresponding values for `monthlysalary`:

    sql-> SELECT id, lastname, income, income/12
    AS monthlysalary FROM users;
     +----+----------+--------+---------------+
     | id | lastname | income | monthlysalary |
     +----+----------+--------+---------------+
     |  2 | Anderson | 100000 |          8333 |
     |  1 | Morrison | 100000 |          8333 |
     |  5 | Scully   | 400000 |         33333 |
     |  4 | Smith    |  80000 |          6666 |
     |  3 | Morgan   |   NULL |          NULL |
     +----+----------+--------+---------------+

    5 rows returned

This SELECT statement performs an addition operation that adds a bonus of 5000 to income to return `salarywithbonus`:

    sql-> SELECT id, lastname, income, income+5000
    AS salarywithbonus FROM users;
     +----+----------+--------+-----------------+
     | id | lastname | income | salarywithbonus |
     +----+----------+--------+-----------------+
     |  4 | Smith    |  80000 |           85000 |
     |  1 | Morrison | 100000 |          105000 |
     |  5 | Scully   | 400000 |          405000 |
     |  3 | Morgan   |   NULL |            NULL |
     |  2 | Anderson | 100000 |          105000 |
     +----+----------+--------+-----------------+

    5 rows returned