SQL Exercises: Display the result of an arithmetic expression
SQL Basic Select Statement: Exercise-5 with Solution.
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.
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://w3resource.com/sql-exercises/sql-retrieve-exercise-5.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics