SQL Exercises: Display the result of an arithmetic expression
Write an SQL query to display the result of an arithmetic expression.
Sample Solution:
-- This query performs a series of arithmetic operations: addition, subtraction, and multiplication.
SELECT 10 + 15 - 5 * 2;
Output of the Query:
?column? 15
Code Explanation:
The given SQL query that selects a column with a single row, which contains the result of the mathematical expression 10 + (15 - (5 * 2)) = 15.
Visual presentation:
Practice Online
Query Visualization:
Duration:
Rows:
Cost:
Have another way to solve this solution? Contribute your code (and comments) through Disqus.
Previous SQL Exercise: Display the sum of two numbers.
Next SQL Exercise: Select specific columns from a table.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics