(Contents)(Previous)(Next)

Arithmetic within the Result List

An SQL query cannot only find data which already exists in a table, but also values which may be calculated from this data.

First the daily prices of the single rooms of all hotels are to be selected:

SELECT hno, roomtype, price

FROM room

WHERE roomtype = 'single'

To obtain the weekly price of a hotel room, the statement can be formulated in the following way:

SELECT hno, roomtype, price*7 price_of_week

FROM room

WHERE roomtype = 'single'

'price*7' is an expression. The weekly price is calculated as the result of the multiplication of 'price' by 7.


(Contents)(Previous)(Next)