SQL tutorial-Field calculations |
||||||||||||||||||||||||||||||
Field calculationsSQL allows you to calculate the fields of a table. The basic
arithmetic operations to calculate the fields are addition(+),
subtraction(-), multiplication(*), and division(/). TblProduct table:
SELECT ProID,UnitPrice*Qty AS Subtotal FROM TblProduct; Result:
Note: We use the AS keyword to assign the new name(Subtotal) to the new
field that derive from the calculation of other fields. This is called
aliasing the field name. |
| |||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||