you tell the database:
What data you want
You generally don't tell the database exactly how to retrieve it internally.
The database's query optimizer determines an efficient execution strategy.
This is one reason SQL is called a declarative language.
๐น 11. SQL KeywordsSQL uses keywords such as:
SELECT
FROM
WHERE
GROUP BY
ORDER BY
HAVING
JOIN
These keywords define the structure of the query.
For example:
SELECT name
FROM customers;
Here:
SELECT โ What to retrieve
FROM โ Where to retrieve it from
๐น 12. SQL Case SensitivitySQL keywords are commonly written in uppercase:
SELECT
FROM
WHERE
This improves readability.
For example:
SELECT customer_id, name
FROM customers;
is easier to read than:
select customer_id,name from customers;
Most SQL database systems treat keywords as case-insensitive, although behavior regarding identifiers such as table and column names can vary by database system and configuration.
Recommended style:
Use:
UPPERCASE for SQL keywords
lowercase or snake_case for column/table names
๐น 13. Column AliasesYou can temporarily give a column a different name using
AS.
Example:
SELECT
name AS customer_name
FROM customers;
The result will display:
customer_name
Alice
Bob
Carol
The original column name in the database is not changed.
The alias only changes how the result is displayed.
๐น 14. Aliases Without ASIn many SQL systems, you can also write:
SELECT
name customer_name
FROM customers;
However, using
AS is generally clearer:
SELECT
name AS customer_name
FROM customers;
๐น 15. Calculations in SELECTSQL can perform calculations.
Suppose we have:
price
quantity
We can calculate total sales:
SELECT
price,
quantity,
price * quantity AS total_amount
FROM orders;
This creates a calculated column:
total_amount = price ร quantityThis ability becomes extremely useful in Data Analytics.
๐น 16. Using SELECT with ExpressionsYou can perform various calculations.
Example:
SELECT
salary,
salary * 12 AS annual_salary
FROM employees;
If monthly salary is:
โน50,000
then:
annual_salary = โน600,000The original database isn't modified.
The calculation is performed when the query runs.
๐น 17. Selecting ConstantsSQL can also return constant values.
Example:
SELECT
'Data Science' AS course;
Result:
course
Data Science
You can also use numbers:
SELECT
2026 AS year;
Result:
year
2026
This becomes useful when constructing analytical datasets.
๐น 18. DISTINCTDISTINCT is part of the roadmap and we'll study it properly later.
For now, understand its basic purpose:
It returns unique values.
Suppose:
cityPune
Mumbai
Pune
Delhi
Mumbai
Query:
SELECT DISTINCT city
FROM customers;
Result:
Pune
Mumbai
Delhi
Duplicate values are removed from the result.
๐น 19. SELECT DISTINCT on Multiple ColumnsYou can use multiple columns:
SELECT DISTINCT city, department
FROM employees;
Important:
DISTINCT applies to the combination of selected columns.
So if two rows have the same city but different departments, they are considered different combinations.
๐น 20. SQL Query ExampleImagine an orders table: