Data Interview Qs - Garbage pickups and remaining capacity

InterviewQs

Garbage pickups and remaining capacity

SQL Database Querying Aggregation Functions Join

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

Hi, 

Suppose you're given two data tables, containing information about the capacity of various unique landfills, along with the associated pickups their trucks are responsible for. A description of the fields is below:

  • table: landfill_info
    • landfill_id - the unique ID of the landfill
    • current_weight_tons - the current weight (in tons) of trash at the landfill
    • capacity_tons - the max capacity (in tons) of trash at the landfill
  • table: landfill_routes
    • landfill_id - the unique ID of the landfill
    • num_pickups - the number of pickups the landfill needs to make (you can ignore the period of time in which the pickups need to be made for this question). Each pickup has an average weight of 0.02 tons

Additionally, below are the tables in their entirety:

landfill_info

landfill_id current_weight_tons capacity_tons
12300 95 200
12401 85 210
992 105 240
882 100 180
11100 55 100
11201 75 160
11207 60 110

landfill_routes

landfill_id num_pickups
12300 1000
12401 500
992 750
882 800
11100 900
11201 400
11207 390

Using the tables above, write a SQL query to return the new current weight of each landfill (after accommodating all of the requested pickups), and return the amount of capacity remaining (capacity_tons - current_weight_tons). If the landfill is over capacity, you can express the remaining capacity as a negative number.

You can view/query the tables in an interactive SQL fiddle here.




 

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

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

Generating automated tax estimates

Monday, February 6, 2023

Python, Algorithms, Logic, InterviewQs Generating automated tax estimates Python Algorithms Logic Forward this email to a friend or colleague and challenge them to solve it. Hi, Suppose you're

Probability of eye colors

Friday, February 3, 2023

Statistics, Probability Theory, Conditional Probability, InterviewQs Probability of eye colors Statistics Probability Theory Conditional Probability Forward this email to a friend or colleague and

Number of pairs in SQL

Wednesday, February 1, 2023

SQL, Database Querying, Subquery, InterviewQs Number of pairs in SQL SQL Database Querying Subquery Forward this email to a friend or colleague and challenge them to solve it. Hi, Suppose you're

Simulating dice rolls

Monday, January 30, 2023

Python, Arrays, Data Structures, Algorithms, Simulation, Data Visualization, InterviewQs Simulating dice rolls Python Arrays Data Structures Algorithms Simulation Data Visualization Forward this email

You Might Also Like

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 ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌

Ranked | The Top 20 Countries in Debt to China 💸

Tuesday, April 30, 2024

The 20 nations featured in this graphic each owe billions in debt to China, often posing concerns for their economic future. View Online | Subscribe Presented by Voronoi: The App Where Data Tells the

Noonification: RaspberryPi: Technology Overload - LAMP🕯 to UASP🐝

Tuesday, April 30, 2024

Top Tech Content sent at Noon! The first AI-powered startup unlocking the “billionaire economy” for your benefit How are you, @newsletterest1? 🪐 What's happening in tech this week: The

Issue #50: ScreenFloat by Matthias Gansrigler

Tuesday, April 30, 2024

Today, we're looking at ScreenFloat by Matthias Gansrigler. ScreenFloat is a screenshot management utility that lets you create floating screenshots so you can easily reference them no matter what