Data Interview Qs - Total revenue by location

InterviewQs

Total revenue by location

SQL Database Querying Joining Tables

Forward this email to a friend or colleague and challenge them to solve it.

Hi, 

Suppose you're given the following tables called 'orders' and 'order_info'. The table 'orders' shows revenue values for unique orders along with the associated channel ('online' or 'in_store') while the table 'order_info' shows the order's ID along with its location.

Table: orders

order_id channel date month revenue
1 online 2020-09-01 00:00:00 9 100
2 online 2020-09-03 00:00:00 9 125
3 in_store 2020-10-11 00:00:00 10 208
4 in_store 2020-08-21 00:00:00 8 80
5 online 2020-08-13 00:00:00 8 200
6 online 2020-08-16 00:00:00 8 210
7 in_store 2020-08-16 00:00:00 8 205
8 online 2020-10-11 00:00:00 10 215
9 online 2020-08-16 00:00:00 8 203
10 in_store 2020-09-01 00:00:00 9 400
11 online 2020-08-01 00:00:00 8 107

Table: order_info

order_id location
1 NYC
2 NYC
3 LAX
4 LAX
5 SEA
6 AUS
7 LON
8 LAX
9 BLD
10 SEA
11 AUS

Using these tables, write a SQL query to return the total revenue by location, sorted by revenue in descending order. You can assume that each order has a unique revenue value, but you should be able to highlight the implications of ties in revenue values and how you would handle that.

Click here to view these tables in an interactive SQL fiddle.


 

You’ve accumulated 321 questions since joining our email list. Create a premium account to access detailed solutions to each problem (including this one) + our new Case studies.


Was this email forwarded to you? You can join our list here to receive questions

How did you like today's question?

15411 Boischatel, Montreal, QC, H9H1Y7, Canada
Don't want to get these emails anymore? We'll forgive you if you unsubscribe

Key phrases

Older messages

Cost per customer acquisition

Monday, July 18, 2022

Python, CDF, PDF, Data Analysis, Pandas, Data Manipulation, External Dataset, InterviewQs Cost per customer acquisition Python CDF PDF Data Analysis Pandas Data Manipulation External Dataset Forward

Clock angle problem

Friday, July 15, 2022

Python, Algorithms, Data Structures, Arrays, InterviewQs Clock angle problem Python Algorithms Data Structures Arrays Forward this email to a friend or colleague and challenge them to solve it. Hi,

Efficacy of a classifier

Thursday, July 14, 2022

Statistics, Machine Learning, ROC Curve, InterviewQs Efficacy of a classifier Statistics Machine Learning ROC Curve Forward this email to a friend or colleague and challenge them to solve it. Hi,

Tree structures in SQL

Monday, July 11, 2022

SQL, Database Querying, Self-join, InterviewQs Tree structures in SQL SQL Database Querying Self-join Forward this email to a friend or colleague and challenge them to solve it. Hi, Suppose you have a

Simulating a marketing campaign

Friday, July 8, 2022

Python, Data Structures, Arrays, Algorithms, Simulation, Data Visualization, InterviewQs Simulating a marketing campaign Python Data Structures Arrays Algorithms Simulation Data Visualization Forward

You Might Also Like

📧 What's inside MMA and how it can help you

Friday, April 26, 2024

What's Inside Modular Monolith Architecture? Hey there! 👋 I wish you an excellent end to the week. What better way to spend the weekend than diving headfirst into a 12+ hour course? Well, maybe

Data Science Weekly - Issue 544

Friday, April 26, 2024

Curated news, articles and jobs related to Data Science, AI, & Machine Learning ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏

Develop highly relevant search applications using AI

Friday, April 26, 2024

New Elasticsearch and AI training ㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤ ㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤ ㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤ elastic | Search. Observe. Protect A world of AI possibilities door-test 2.png Explore

Stripe makes more changes

Thursday, April 25, 2024

TikTok is in trouble, and net neutrality is back View this email online in your browser By Christine Hall Thursday, April 25, 2024 Welcome back to TechCrunch PM, your home for all things startups,

💎 Issue 414 - From a Lorry Driver to Ruby on Rails Developer at 38

Thursday, April 25, 2024

This week's Awesome Ruby Newsletter Read this email on the Web The Awesome Ruby Newsletter Issue » 414 Release Date Apr 25, 2024 Your weekly report of the most popular Ruby news, articles and

💻 Issue 414 - JavaScript Features That Most Developers Don’t Know

Thursday, April 25, 2024

This week's Awesome Node.js Weekly Read this email on the Web The Awesome Node.js Weekly Issue » 414 Release Date Apr 25, 2024 Your weekly report of the most popular Node.js news, articles and

💻 Issue 407 - The Performance Impact of C++'s `final` Keyword

Thursday, April 25, 2024

This week's Awesome .NET Weekly Read this email on the Web The Awesome .NET Weekly Issue » 407 Release Date Apr 25, 2024 Your weekly report of the most popular .NET news, articles and projects

💻 Issue 414 - Everyone Has JavaScript, Right?

Thursday, April 25, 2024

This week's Awesome JavaScript Weekly Read this email on the Web The Awesome JavaScript Weekly Issue » 414 Release Date Apr 25, 2024 Your weekly report of the most popular JavaScript news, articles

📱 Issue 408 - All web browsers on iOS are just Safari with different design

Thursday, April 25, 2024

This week's Awesome iOS Weekly Read this email on the Web The Awesome iOS Weekly Issue » 408 Release Date Apr 25, 2024 Your weekly report of the most popular iOS news, articles and projects Popular

💧 Don't Bother Liquid Cooling Your AMD CPU — Why You Should Keep Using Live Photos on iPhone

Thursday, April 25, 2024

Also: We review the Unistellar Odyssey iPhone Telescope, and More! How-To Geek Logo April 25, 2024 Did You Know Charles Darwin and Abraham Lincoln were both born on the same day: February 12, 1809. 💻