Profit margins for all combinations of sales channels by org

InterviewQs

Profit margins for all combinations of sales channels by org

SQL Database Querying Subquery Cross Join

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

Hi, 

Suppose you're looking to calculate the net profit margin for each combination of sales org and sales channel. You're given the following tables to work with:

Table: sales_org

sales_org_id sales_org
1 Small/Medium Business
2 Consumer
3 Enterprise

Table: sales_channel

channel_id channel
1 Direct from Manufacturer
2 Retail
3 eCommerce
4 TV Shopping

Table: sale_info

channel_id channel_cost sales_org_id sales_org_revenue
1 700 2 1200
2 1200 1 1450
3 850 3 1000
4 920 2 940
2 500 3 600

Using the above tables, write a SQL query to return the following:

  • Net profit margin (sales_org_revenue - channel_cost) for all combinations of sales_org and channel (e.g. you'll need to JOIN on both sales_org_id and channel_id)
  • For those combinations that have no revenue or cost data, you're still asked to return the rows, but you can mark revenue, cost, and profit all as 0

Click here to view/query the tables in an interactive SQL fiddle.


 

You’ve accumulated 285 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

Damage due to natural disasters

Monday, April 25, 2022

Python, Data Structures, External Dataset, Data Visualization, Data Processing, InterviewQs Damage due to natural disasters Python Data Structures External Dataset Data Visualization Data Processing

Maximizing value of your knapsack

Friday, April 22, 2022

Python, Arrays, Data Structures, Algorithms, InterviewQs Maximizing value of your knapsack Python Arrays Data Structures Algorithms Forward this email to a friend or colleague and challenge them to

Normalizing cholesterol data

Wednesday, April 20, 2022

Python, Normalizing Data, ML Concept, Data Processing, InterviewQs Normalizing cholesterol data Python Normalizing Data ML Concept Data Processing Forward this email to a friend or colleague and

Allocating votes from pooled elections

Monday, April 18, 2022

SQL, Database Querying, Subquery, InterviewQs Allocating votes from pooled elections SQL Database Querying Subquery Forward this email to a friend or colleague and challenge them to solve it. Hi,

Estimating the confidence interval for the length of an angelfish

Monday, April 11, 2022

Statistics, Confidence Intervals, InterviewQs Estimating the confidence interval for the length of an angelfish Statistics Confidence Intervals Forward this email to a friend or colleague and challenge

You Might Also Like

Introducing SwiftUI to the team, Let loose and much more!

Friday, April 26, 2024

View in browser Hello, you're reading Infinum iOS Cocoa Treats, bringing you the latest iOS related news straight to your inbox every week. How We Got Everyone on Board with a New Technology

SWLW #596: SRE and the art of improvisation, The power of celebration, and more.

Friday, April 26, 2024

Weekly articles & videos about people, culture and leadership: everything you need to design the org that makes the product. A weekly newsletter by Oren Ellenbogen with the best content I found

Notion's New Look | In-App Notifications | Duplicated Automations

Friday, April 26, 2024

Your weekly Notion digest with the finest tip, latest news, and improvements! 🔥 ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏

Don’t celebrate the demise of non-competes quite yet

Friday, April 26, 2024

A slew of lawsuits are heading the FTC's way after it voted to kill non-competes View this email online in your browser By Alex Wilhelm Friday, April 26, 2024 Welcome to TechCrunch AM! I love this

The best work laptop for most people

Friday, April 26, 2024

Old Kindle? Don't do this; How to change your IP address; Net neutrality restored -- ZDNET ZDNET Tech Today - US April 26, 2024 placeholder The work laptop I recommend to most people is not made by

New 'Brokewell' Android Banking Malware Spread Through Fake Browser Updates

Friday, April 26, 2024

THN Daily Updates Newsletter cover Webinar -- Uncovering Contemporary DDoS Attack Tactics -- and How to Fight Back Stop DDoS Attacks Before They Stop Your Business... and Make You Headline News.

Apple announces an iPad event for May 7

Friday, April 26, 2024

The Morning After It's Friday, April 26, 2024. Apple has scheduled its next product showcase for May 7, a few weeks before its Worldwide Developers Conference, clearing space for even more

[AI Incubator] Enrollment ends tonight.

Friday, April 26, 2024

Text or WhatsApp me your questions ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌

Post from Syncfusion Blogs on 04/26/2024

Friday, April 26, 2024

New blogs from Syncfusion Create Excel Table in Just 3 Steps Using C# By Mohan Chandran This blog explains how to create a table in an Excel document using Syncfusion .NET Excel Library in C# with code

ASP.NET Core News - 04/26/2024

Friday, April 26, 2024

View this email in your browser Get ready for this weeks best blog posts about ASP.NET Core! This newsletter is sponsored by elmah.io - the most advanced, yet so simple to set up, error logging and