KDATA SQLD Scope
Used as the exam-oriented baseline for data modeling, SELECT, WHERE, JOIN, GROUP BY, subqueries, set operators, window functions, and management statements.
KDATA SQLD guideVerified concept notes
These notes summarize SQL concepts using official documentation from KDATA, PostgreSQL, MySQL, and Oracle as the baseline. Read the concept first, then move directly into matching practice problems.
Source baseline
The goal is to give learners a reliable summary before practice, while linking back to the original documentation for deeper study.
Used as the exam-oriented baseline for data modeling, SELECT, WHERE, JOIN, GROUP BY, subqueries, set operators, window functions, and management statements.
KDATA SQLD guideUsed for SELECT, WHERE, ORDER BY, joins, aggregate functions, GROUP BY, HAVING, and window function behavior.
PostgreSQL SELECT tutorialUsed for SELECT syntax, NULL behavior, and window function concepts such as OVER, PARTITION BY, and window ordering.
MySQL SELECT referenceUsed for set operator rules, including UNION, UNION ALL, INTERSECT, EXCEPT, and MINUS compatibility requirements.
Oracle set operatorsKDATA SQLD scope
KDATA's SQLD information groups the exam around data modeling and SQL fundamentals. SQLHub follows that direction by connecting modeling, table relationships, SELECT, functions, WHERE, GROUP BY, HAVING, ORDER BY, joins, subqueries, set operators, window functions, and management statements to practical query problems.
SELECT, WHERE, ORDER BY, DISTINCT
Official SQL documentation treats SELECT as a statement that defines the output columns, source tables, and optional conditions. WHERE keeps rows that satisfy a condition. ORDER BY is what makes output order predictable. DISTINCT removes duplicate result rows, but it should not be treated as a replacement for ORDER BY.
SELECT DISTINCT category
FROM products
WHERE price >= 50
ORDER BY category;
JOIN and relationships
PostgreSQL's documentation explains joins as queries that process multiple tables, or multiple instances of the same table, at once. INNER JOIN returns matching rows. LEFT OUTER JOIN keeps rows from the left table and fills missing right-side values with NULL. A self join uses the same table with different aliases.
SELECT c.name, o.id AS order_id
FROM customers AS c
LEFT JOIN orders AS o
ON c.id = o.customer_id;
GROUP BY, HAVING, aggregates
Aggregate functions calculate one result from multiple input rows. WHERE decides which input rows enter the grouping step. GROUP BY forms groups. HAVING filters those groups after aggregate values such as COUNT, SUM, and AVG have been calculated.
SELECT customer_id, COUNT(*) AS order_count
FROM orders
WHERE total_amount > 0
GROUP BY customer_id
HAVING COUNT(*) >= 2;
Subqueries
A subquery is useful when the outer query needs a value or set of values computed by another query. Use scalar subqueries for one value, IN for a list of candidate values, and EXISTS or NOT EXISTS when the question is about whether related rows exist.
SELECT *
FROM orders
WHERE total_amount > (
SELECT AVG(total_amount)
FROM orders
);
NULL handling
MySQL's documentation explains that NULL has special behavior in DISTINCT, GROUP BY, ORDER BY, and aggregate functions. COUNT(column) ignores NULL values, while COUNT(*) counts rows. For conditions, use IS NULL or IS NOT NULL instead of = NULL.
SELECT id, COALESCE(nickname, name) AS display_name
FROM users
WHERE deleted_at IS NULL;
UNION, INTERSECT, EXCEPT
Oracle's SQL Reference explains that set operators combine result sets and require matching numbers of expressions with compatible data type groups. UNION removes duplicates. UNION ALL preserves duplicates.
SELECT email FROM customers
UNION
SELECT email FROM newsletter_signups
ORDER BY email;
Window functions and Top N
PostgreSQL's documentation explains that window functions do not group output rows into a single row. MySQL's documentation shows that functions such as ROW_NUMBER use OVER, and that PARTITION BY plus window ORDER BY defines how rows are numbered or ranked.
SELECT id, customer_id, total_amount,
ROW_NUMBER() OVER (
PARTITION BY customer_id
ORDER BY total_amount DESC
) AS customer_order_rank
FROM orders;