Search GimmeJob

Type at least 2 characters. Enter also searches by meaning.
QA interview question
Databases, SQL & BISQL languageJuniorCommonPractical

How would you explain INNER JOIN, LEFT JOIN, grouping and aggregation during a data-validation task?

Answer

INNER JOIN returns matching rows from both sides; LEFT JOIN retains every left-side row and adds matching right data. GROUP BY forms sets for aggregate functions such as COUNT or SUM, while HAVING filters groups after aggregation.

Strong answer includes

  • matching versus retained rows
  • grouping before aggregation
  • WHERE versus HAVING

Practical example

Compare JOIN behavior and aggregate groups
Dialect · Portable SQLRuntime · SQLite sample DB

Runs against the resettable SQLite sample database used by the playground.

SQL
SQLite · sample DB · browser sandbox
Result
Run the query to see the result.

INNER JOIN removes left-side rows without a match; LEFT JOIN preserves them and fills right-side columns with NULL. GROUP BY creates one aggregate group per customer, aggregate functions calculate values for each group, and HAVING filters those groups after aggregation. COUNT(o.id), rather than COUNT(*), keeps zero-order customers from being counted as one joined row.

Expected result: The first query contains only matched customers/orders; the second returns customers with at least two orders and their aggregated spend.

#sql#joins#aggregation

Sources

PostgreSQL documentationPostgreSQL Global Development Group · Relational modelling, SQL, joins, constraints, transactions, concurrency, indexes, query plans and recoveryDOU — QA interview: 250+ questionsDOU · Coverage signal across Junior, Middle, Senior, AQA, web, mobile and practical topics