TSO-ISPF JCL COBOL VSAM DB2 CICS Tools Articles Job Portal Forum Quiz Interview Q&A

DB2 - SQL Mathematical Operators


SQL Mathematical Operators are as follows:

OperatorDescription
+Addition
-Subtraction
*Multiplication
/Division

DB2 Database:

Below is a selection from the "Students" table in the DB2 database.

StudentidStudentnameMark1Mark2Mark3
1001Mani1008090
1002Sini1008595
1003Thamarai10090100
1004Kalai908090
1005Pravin758060
1006Asaimani607090


Example 1:

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;

Result:
StudentidStudentnameMark1Mark2Mark3Total marks
1001Mani1008090270
1002Sini1008595280
1003Thamarai10090100290
1004Kalai908090260
1005Pravin758060215
1006Asaimani607090220


If you have any doubts or queries related to this chapter, get them clarified from our Mainframe experts on ibmmainframer Community!

Are you looking for Job Change? Job Portal