FlashKeepers

SQL · SQL · College and University

SQL Joins and Aggregate Functions

Join types (inner, left, right, full) and aggregate functions with GROUP BY, each explained with a short example.

About this set

36 basic cards for SQL SQL. It opens with "What is an INNER JOIN?" and "What is a LEFT JOIN (LEFT OUTER JOIN)?". More College and University decks are listed below.

36 cards · basic cards · AI-written, checked twice. Edit anything.

Study this set free Look inside first Get FlashKeepers for iPhone

Opens in your browser, no account. Get the iPhone and iPad app · Android app

What is an INNER JOIN?
Show answerReturns only rows where the join condition is met in both tables
What is a LEFT JOIN (LEFT OUTER JOIN)?
Show answerReturns all rows from the left table, with matching rows from the right table; NULLs for non-matches
What is a RIGHT JOIN (RIGHT OUTER JOIN)?
Show answerReturns all rows from the right table, with matching rows from the left table; NULLs for non-matches
What is a FULL OUTER JOIN?
Show answerReturns all rows from both tables; NULLs for non-matching sides
Write a basic INNER JOIN
Show answerSELECT * FROM users INNER JOIN orders ON users.id = orders.user_id
Write a basic LEFT JOIN
Show answerSELECT * FROM users LEFT JOIN orders ON users.id = orders.user_id
Write a basic RIGHT JOIN
Show answerSELECT * FROM users RIGHT JOIN orders ON users.id = orders.user_id
Write a basic FULL OUTER JOIN
Show answerSELECT * FROM users FULL OUTER JOIN orders ON users.id = orders.user_id
What is the COUNT() aggregate function?
Show answerCounts rows; COUNT(*) counts all rows, COUNT(column) counts non-null values
What is the SUM() aggregate function?
Show answerAdds together all values in a numeric column; ignores NULL
What is the AVG() aggregate function?
Show answerCalculates the average of values in a numeric column; ignores NULL
What is the MIN() aggregate function?
Show answerReturns the smallest value in a column
What is the MAX() aggregate function?
Show answerReturns the largest value in a column
What is GROUP_CONCAT() or STRING_AGG()?
Show answerConcatenates values from multiple rows into a single string
Does COUNT(*) count NULL values?
Show answerYes, COUNT(*) counts all rows including any with NULL

21 more cards in the app

Study this set free