Perform arithmetic operation in SQL

SQL allows you to perform arithmetic operations using standard operators like +, -, *, and /. However, these operations are restricted to working on values within the same row, meaning you can only combine columns from a single row. To perform calculations across multiple rows, such as adding values from different rows, you’ll need to use aggregate functions like SUM. Examples are mentioned below: Example


SELECT student_name, (math_marks + english_marks + science_marks) AS total_marks
FROM student_marks;
Example


SELECT product_name, (selling_price - cost_price) AS profit
FROM profit_loss_table;