Locations with the lowest in store revenue

InterviewQs

Locations with the lowest in store revenue

SQL Database Querying Window Function Subquery

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 2 locations with the lowest 'in_store' revenue generated. 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 413 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

Countries with the highest rates of diabetes

Friday, February 17, 2023

Data Analysis, Python, Pandas, Data Manipulation, External Dataset, InterviewQs Countries with the highest rates of diabetes Data Analysis Python Pandas Data Manipulation External Dataset Forward this

Returning duplicate elements in an array

Friday, February 17, 2023

Python, Algorithms, InterviewQs Returning duplicate elements in an array Python Algorithms Forward this email to a friend or colleague and challenge them to solve it. Hi, Suppose you're given an

iPhone power button quality

Monday, February 13, 2023

Statistics, Significance Testing, Case Study, InterviewQs iPhone power button quality Statistics Significance Testing Case Study Forward this email to a friend or colleague and challenge them to solve

Garbage pickups and remaining capacity

Friday, February 10, 2023

SQL, Database Querying, Aggregation Functions, Join, InterviewQs Garbage pickups and remaining capacity SQL Database Querying Aggregation Functions Join Forward this email to a friend or colleague and

College football expenses by conference

Wednesday, February 8, 2023

Data Analysis, Python, Pandas, Data Manipulation, External Dataset, InterviewQs College football expenses by conference Data Analysis Python Pandas Data Manipulation External Dataset Forward this email

You Might Also Like

JSter #218 - Libraries and more

Wednesday, May 1, 2024

All JavaScript is good JavaScript. I'm close to done with my SurviveJS rework. The new site will have more content while being much lighter and faster to compile so that's all good. Libraries

BetterDev #258 - Build an 8-bit computer from scratch and Home automation with ESP8266

Wednesday, May 1, 2024

Better Dev #258 Apr 30, 2024 Hi all, We come back with a new issue this week. If you like BetterDev, please help spead word out by refer to your friends. Buy me a coffee would be great too. Build an 8-

Interface Interference 👎

Wednesday, May 1, 2024

Amid the AI device dunking, should everything “just be an app”? Here's a version for your browser. Hunting for the end of the long tail • April 30, 2024 Interface Interference The problem

Some Tesla Supercharger jobs get a jolt

Tuesday, April 30, 2024

Plus: Amazon CodeWhisperer changes its name and Arc gets a Windows version View this email online in your browser By Christine Hall Tuesday, April 30, 2024 Welcome to TechCrunch PM, bringing you the

Relief From Tinnitus: Free Discovery Call!

Tuesday, April 30, 2024

Do you suffer from tinnitus or a ringing in your ears? 1 in 3 adults over the age of 65 will suffer from this condition and often don't know there are things you can do to help. Our friends at

WebAIM April 2024 Newsletter

Tuesday, April 30, 2024

WebAIM April 2024 Newsletter Read this newsletter online at https://webaim.org/newsletter/2024/april Feature Web Accessibility in the 2024 Presidential Campaigns WebAIM's John Northup ran the US

👀 Being More Productive on a Smaller Screen — How to Hide Games on Steam Family Sharing

Tuesday, April 30, 2024

Also: What to Expect From Apple's "Let Loose" Event, and More! How-To Geek Logo April 30, 2024 Did You Know The letter J is the only letter that makes no appearance on the Periodic Table.

PEP 686, Lazy Evaluation, Serverless Python, and More

Tuesday, April 30, 2024

PEP 686: Make UTF-8 Mode Default #627 – APRIL 30, 2024 VIEW IN BROWSER The PyCoder's Weekly Logo PEP 686: Make UTF-8 Mode Default This Python Enhancement Proposal outlines making UTF-8 the default

Daily Coding Problem: Problem #1427 [Easy]

Tuesday, April 30, 2024

Daily Coding Problem Good morning! Here's your coding interview problem for today. This problem was asked by Amazon. Given an array and a number k that's smaller than the length of the array,

🎙 My advice for film + TV creatives on the AI wave

Tuesday, April 30, 2024

Learning AI fast + Karate Kid references ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌