JOINs & Aggregations
SELECT u.name, COUNT(p.id) as total_posts
FROM users u
LEFT JOIN posts p ON p.author_id = u.id
GROUP BY u.name
ORDER BY total_posts DESC;Aggregate user post counts using LEFT JOIN and GROUP BY
SELECT name, salary,
DENSE_RANK() OVER (ORDER BY salary DESC) as rank
FROM employees;Window function ranking employees by salary without grouping rows
ACID Transactions
BEGIN;
UPDATE accounts SET balance = balance - 100 WHERE id = 1;
UPDATE accounts SET balance = balance + 100 WHERE id = 2;
COMMIT;Atomic transfer transaction with full rollback safety
Amaliy Maslahatlar va Xavfsizlik
Add B-Tree indexes on columns frequently filtered in WHERE or joined in JOIN
Inspect execution bottlenecks with EXPLAIN (ANALYZE, BUFFERS)