SELECT (DISTINCT)
DISTINCT: OptionalRetrieves rows from a database, with DISTINCT
filtering out duplicate records.
Copy
SELECT DISTINCT customer_id
FROM orders
JOIN
Combines rows from two or more tables based on a related column between them. Supports FULL JOIN, INNER JOIN, LEFT JOIN, RIGHT JOIN.
Copy
SELECT orders . order_id , customers . customer_name
FROM orders
JOIN customers
ON orders . customer_id = customers . customer_id
GROUP BY
Groups rows that have the same values in specified columns into summary rows.
Copy
SELECT product_id , SUM ( quantity )
FROM sales
GROUP BY product_id
WHERE
Includes support for LIKE
, IN
, ON
, OR
filters.Filters records that meet a specified condition.
Copy
SELECT *
FROM employees
WHERE department = 'Sales' AND name LIKE 'J%'
CASE
Provides conditional logic to return different values based on specified conditions.
Copy
SELECT order_id ,
CASE
WHEN quantity > 10 THEN 'Bulk Order'
ELSE 'Standard Order'
END AS order_type
FROM orders
WINDOW
Performs a calculation across a set of table rows that are related to the current row.
Copy
SELECT
timestamp ,
service_name ,
cpu_usage_percent ,
AVG ( cpu_usage_percent ) OVER ( PARTITION BY service_name ORDER BY timestamp ROWS BETWEEN 2 PRECEDING AND CURRENT ROW ) AS moving_avg_cpu
FROM
cpu_usage_data
IS NULL
/ IS NOT NULL
Checks if a value is null or not null.
Copy
SELECT *
FROM orders
WHERE delivery_date IS NULL
LIMIT
Specifies the maximum number of records to return.
Copy
SELECT *
FROM customers
LIMIT 10
ORDER BY
Sorts the result set of a query by one or more columns. Includes ASC, DESC for sorting order.
Copy
SELECT *
FROM sales
ORDER BY sale_date DESC
HAVING
Filters records that meet a specified condition after grouping.
Copy
SELECT product_id , SUM ( quantity )
FROM sales
GROUP BY product_id
HAVING SUM ( quantity ) > 10
IN
, ON
, OR
Used for specified conditions in queries. Available in WHERE
, JOIN
clauses.
Copy
SELECT *
FROM orders
WHERE order_status IN ( 'Shipped' , 'Pending' )
AS
Renames a column or table with an alias.
Copy
SELECT first_name AS name
FROM employees
Arithmetic Operations Performs basic calculations using operators like +
, -
, *
, /
.
Copy
SELECT price , tax , ( price * tax ) AS total_cost
FROM products
INTERVAL value unit
interval Represents a time duration specified in a given unit.