Company: Slack | Difficulty: easy
Write a query to return the post_id and the team_name for every post. Combine the user_posts and teams tables using their shared team identifier.
post_id
team_name
user_posts
teams
Sort the results by post_id in descending order.
team_id
Posts 1 and 2 belong to the Core Platform team, while post 3 belongs to the Enterprise Sales team. The result is ordered by post_id from highest to lowest.
Core Platform
Enterprise Sales
DROP TABLE IF EXISTS user_posts; DROP TABLE IF EXISTS teams; CREATE TABLE user_posts ( post_id INT, team_id INT ); CREATE TABLE teams ( team_id INT, team_name VARCHAR(80) ); INSERT INTO user_posts VALUES (1, 10), (2, 10), (3, 20); INSERT INTO teams VALUES (10, 'Core Platform'), (20, 'Enterprise Sales');
← All SQL Challenges · Slack Questions · Learn SQL Free