Beginner

37. SQL Constants

Understand constants or fixed values that can be directly written inside SQL queries.

📘 Lesson 37 of 728 ⏱ 7 min 🎯 Beginner

A SQL constant is a fixed value written directly in a SQL statement rather than retrieved from a table column. Constants can be numeric values, string values, date values, or other supported literal values. They are commonly used in calculations, comparisons, conditions, and expressions.

Constants allow analysts to define fixed business conditions directly inside queries. For example, a salary threshold or a specific department can be used as a constant in a WHERE condition.

In a condition such as Salary > 50000, the value 50000 is a numeric constant used as a fixed comparison value.

SQL
SELECT
    EmployeeName,
    Salary
FROM Employees
WHERE Salary > 50000;

Constants are commonly used for thresholds, business rules, fixed categories, dates, percentages, and comparison values.

  • Constants are fixed values.
  • Constants can be numeric.
  • Constants can be text values.
  • Constants can represent dates.
  • Constants are commonly used in conditions and calculations.
What is a SQL constant?

A SQL constant is a fixed value written directly in a SQL statement.

Give an example of a SQL constant.

In Salary > 50000, the value 50000 is a numeric constant.

Have you finished this lesson?

Introduction to SQL – All Lessons