SQL & Databases Masterclass Course
Welcome to the ultimate postgresql tutorial for beginners 2026. Work through interactive sql practice problems with solutions, master our comprehensive sql window functions tutorial modules, and prepare for tough sql interview questions at Google and Amazon entirely in your browser. Claim your course completion XP and build production-ready database mastery today!
SQL Lesson 9: Queries with expressions
Introduction & Core Concept
SQL is not just a data retrieval engine; it is a high-speed mathematical calculation engine. You can execute arithmetic operators (+, -, *, /) directly on numeric attributes during query execution to derive new insights instantly.
SELECT salary, salary * 1.10 AS salary_with_ten_percent_raise
FROM employees;You can also leverage built-in mathematical functions like ROUND(value, decimal_places) to keep floating-point currency outputs beautifully formatted.
Why & Where We Use It
Real-World Example
The finance department at ApexBank wants to forecast the annual interest expenses payable on all active customer loans. They multiply the loan balance by the interest rate percentage divided by 100, rounding the final cost to two decimal places.
Best Practices: What to Do & What NOT to Do
.0 to integers (e.g., rate / 100.0). In some SQL engines, dividing two integers performs integer division, silently dropping fractional decimal remainders!NULLIF(divisor_column, 0).Syntax & Pro Tips
SELECT
loan_amount,
interest_rate,
ROUND(loan_amount * (interest_rate / 100.0), 2) AS annual_interest_payable
FROM bank_loans;