Fundamentals of Business Analytics
Online B.Com · Sem 5
0% complete
0/4 lessons
Lesson 3 of 4Analytics
SQL Queries for Business Data
Fundamentals of Business Analytics
About the video
Learn Basic SQL in 15 Minutes | Business Intelligence For Beginners | SQL Tutorial For Beginners 1/3
Adam Finer - Learn BI
Study notes
SQL (Structured Query Language) is used to retrieve and summarize business data stored in relational databases. The core queries combine SELECT, FROM, WHERE, GROUP BY, HAVING, ORDER BY and JOINs to answer business questions.
Basic Query Structure
- SELECT columns FROM table chooses which data to return.
- WHERE filters rows, e.g. WHERE region = 'East' AND sales > 1000.
- ORDER BY column ASC/DESC sorts the results; LIMIT restricts the number of rows returned.
- DISTINCT removes duplicate rows.
Aggregation
- Aggregate functions: COUNT, SUM, AVG, MIN, MAX.
- GROUP BY produces one summary row per group, e.g. SELECT region, SUM(sales) FROM orders GROUP BY region.
- HAVING filters groups after aggregation; WHERE filters rows before aggregation.
Joins
- INNER JOIN returns only rows that match in both tables.
- LEFT JOIN returns all rows from the left table plus any matches; unmatched columns are NULL.
- Tables are joined on keys, e.g. orders.customer_id = customers.id.
Logical Execution Order
- FROM/JOIN, then WHERE, then GROUP BY, then HAVING, then SELECT, then ORDER BY, then LIMIT.
Key terms
- SELECT
- Clause that specifies which columns or expressions to return.
- WHERE
- Clause that filters individual rows before grouping.
- GROUP BY
- Clause that groups rows so aggregates are calculated per group.
- HAVING
- Clause that filters groups based on aggregate values.
- JOIN
- Operation that combines rows from tables using related key columns.
- Primary/Foreign Key
- A unique row identifier, and a column referencing that identifier in another table.
Takeaways
- Use WHERE for row filters and HAVING for aggregate filters.
- Every non-aggregated column in SELECT must appear in GROUP BY.
- Use INNER JOIN for matches only and LEFT JOIN to keep all rows from the left table.
- Answering business questions usually means combining filtering, grouping and sorting.
Contribute
Was this lesson helpful?
We read every rating and fix the weakest lessons first.