Deep dive into Data Query Language (retrieving), Data Definition Language (structuring), and Data Manipulation Language (modifying).
DQL is used to fetch data from the database. The most common command is SELECT. It allows you to retrieve specific columns, filter rows, aggregate data, and join multiple tables.
SQL doesn't execute from top to bottom like other code. The database engine processes clauses in a specific order:
Get specific columns for customers from 'Geometry':
SELECT first_name, countryFROM CustomersWHERE country = 'Germany';
Sort by score (High to Low). If scores match, then alphabetically.
Note: Default sort is ASC (Ascending).
SELECT *FROM CustomersORDER BY score DESC, name ASC;
Concept:
Find countries with total customer score higher than 800:
SELECT country, SUM(score)FROM CustomersGROUP BY countryHAVING SUM(score) > 800;
SELECT * FROM Customers LIMIT 5;
SELECT TOP 5 * FROM Customers;