SQL Mathematical Operators are as follows:
Operator | Description |
---|---|
+ | Addition |
- | Subtraction |
* | Multiplication |
/ | Division |
Below is a selection from the "Students" table in the DB2 database.
Studentid | Studentname | Mark1 | Mark2 | Mark3 |
---|---|---|---|---|
1001 | Mani | 100 | 80 | 90 |
1002 | Sini | 100 | 85 | 95 |
1003 | Thamarai | 100 | 90 | 100 |
1004 | Kalai | 90 | 80 | 90 |
1005 | Pravin | 75 | 80 | 60 |
1006 | Asaimani | 60 | 70 | 90 |
The following SQL statement list the students details with totol marks.
SELECT Studentid, Studentname, Mark1, Mark2, Mark3, Mark1+Mark2+Mark3 AS "Total marks" FROM Students; |
Studentid | Studentname | Mark1 | Mark2 | Mark3 | Total marks |
---|---|---|---|---|---|
1001 | Mani | 100 | 80 | 90 | 270 |
1002 | Sini | 100 | 85 | 95 | 280 |
1003 | Thamarai | 100 | 90 | 100 | 290 |
1004 | Kalai | 90 | 80 | 90 | 260 |
1005 | Pravin | 75 | 80 | 60 | 215 |
1006 | Asaimani | 60 | 70 | 90 | 220 |
If you have any doubts or queries related to this chapter, get them clarified from our Mainframe experts on ibmmainframer Community!