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
| Item | Quantity | Price | Reduction | Total |
|---|---|---|---|---|
| Item1 | 5 | 400 | 10 | 2000 |
| Item2 | 6 | 300 | 10 | 1800 |
| Item3 | 3 | 15 | 5 | 45 |
| Item4 | 2 | 30 | 5 | 60 |
| Item5 | 2 | 300 | 5 | 600 |
| Item6 | 6 | 400 | 10 | 2400 |
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
| Item | Total |
|---|---|
| Item1 | 2000 |
| Item2 | 1800 |
| Item3 | 45 |
| Item4 | 60 |
| Item5 | 600 |
| Item6 | 2400 |
SQL Functions
- Upper
- Lower
- Substring
- Date
- ABS
- Cos
- exp
- pi
- sin
- sqrt
- tan
No comments:
Post a Comment