Data Interview Qs - Top online order locations by revenue

InterviewQs

Top online order locations by 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 top 3 'online' orders and their associated locations based on 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 273 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

Older messages

Probability of sitting in the aisle based on the plane ticket's letter

Monday, March 28, 2022

Python, Probability, Data Structures, Pandas, Data Analysis, Data Visualization, InterviewQs Probability of sitting in the aisle based on the plane ticket's letter Python Probability Data

Words from keyboard rows

Friday, March 25, 2022

Python, Arrays, Data Structures, Algorithms, InterviewQs Words from keyboard rows Python Arrays Data Structures Algorithms Forward this email to a friend or colleague and challenge them to solve it. Hi

Selecting eggs from the grocery store

Wednesday, March 23, 2022

Statistics, Probability Theory, Bayes' Theorem, Conditional Probability, InterviewQs Selecting eggs from the grocery store Statistics Probability Theory Bayes' Theorem Conditional Probability

Flagging increasing stock prices in SQL

Monday, March 21, 2022

SQL, Database Querying, Window Function, Subquery, InterviewQs Flagging increasing stock prices in SQL SQL Database Querying Window Function Subquery Forward this email to a friend or colleague and

Large numbers in a raffle

Friday, March 18, 2022

Statistics, Probability Theory, Binomial, InterviewQs Large numbers in a raffle Statistics Probability Theory Binomial Forward this email to a friend or colleague and challenge them to solve it. Hi,

You Might Also Like

JSK Daily for May 4, 2024

Saturday, May 4, 2024

JSK Daily for May 4, 2024 View this email in your browser A community curated daily e-mail of JavaScript news The Power of React's Virtual DOM: A Comprehensive Explanation Modern JavaScript

Daily Coding Problem: Problem #1431 [Medium]

Saturday, May 4, 2024

Daily Coding Problem Good morning! Here's your coding interview problem for today. This problem was asked by MongoDB. Given a list of elements, find the majority element, which appears more than

Ranked | The World's Top Media Franchises by All-Time Revenue 📊

Saturday, May 4, 2024

From Pokémon to Star Wars, some media franchises are globally recognizable. How do media franchises compare in terms of all-time revenue? View Online | Subscribe Presented by Voronoi: The App Where

Noonification: Read Code Like a Hacker With the SAST

Saturday, May 4, 2024

Top Tech Content sent at Noon! Get Algolia: AI Search that understands How are you, @newsletterest1? 🪐 What's happening in tech today, May 4, 2024? The HackerNoon Newsletter brings the HackerNoon

Weekend Reading — May the fourth

Saturday, May 4, 2024

This week we setup our new Minecraft server, play Spacewar, avoid burnout, wonder about Facebook AI spam, lose our passkeys, and claim stairs on the way back home. 😎 Labnotes (by Assaf Arkin) Weekend

Google lays off workers

Saturday, May 4, 2024

Plus: Tesla cans its Supercharger team and UnitedHealthcare reveals security lapses View this email online in your browser By Kyle Wiggers Saturday, May 4, 2024 Image Credits: Tomohiro Ohsumi / Getty

When It Rains, It Pours ☔

Saturday, May 4, 2024

Why the umbrella's design can't be beat. Here's a version for your browser. Hunting for the end of the long tail • May 04, 2024 Hey there, Ernie here with a refreshed piece about umbrellas

🐍 New Python tutorials on Real Python

Saturday, May 4, 2024

Hey there, There's always something going on over at realpython.com as far as Python tutorials go. Here's what you may have missed this past week: Python's unittest: Writing Unit Tests for

Microsoft Outlook Flaw Exploited by Russia's APT28 to Hack Czech, German Entities

Saturday, May 4, 2024

THN Daily Updates Newsletter cover Webinar -- Data Security is Different at the Petabyte Scale Discover the secrets to securing fast-moving, massive data sets with insights from industry titans

Stop spam texts today!

Saturday, May 4, 2024

Have you been receiving a ton of spam texts lately? In April alone, spammers sent out over 19.2 billion texts. Ever wonder where they get your info to begin with? Data brokers. They sell your address,