Monday, November 23, 2015

SQL Mathematical Operators

SQL Calculation fields can be used to perform mathematical ( + , - , * , /) operation on retrieved data. SQL Query with different mathematical operations performed on the table sales is given below
Table Name : Sales
ItemQuantityPriceReductionTotal
Item15400102000
Item26300101800
Item3315545
Item4230560
Item523005600
Item66400102400

For multiplication , following SQL Query is used . For example, Query to find the total of each based on the quantity and base price
select items, quantity* price Total from sales
ItemTotal
Item12000
Item21800
Item345
Item460
Item5600
Item62400

Similarly mathematical operators ( - , + , % ) can be used in query.

SQL Functions

  • Upper
  • Lower
  • Substring
  • Date
  • ABS
  • Cos
  • exp
  • pi
  • sin
  • sqrt
  • tan

No comments: