Data Interview Qs - Histogram of daily sales in SQL

InterviewQs

Histogram of daily sales in SQL

SQL Database Querying Subquery Histogram

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

Hi, 

Suppose you’re given the following tables, showing sales across a 10-day period:

Table: item_sales

day num_sales
1 1055
2 500
3 300
4 1400
5 900
6 1000
7 1100
8 800
9 1350
10 1000

Using this table, write a SQL query to count the number of days where sales fall into bands of 200 (e.g. a histogram). Given the snippet of data in this example, your query should return the following:

bucket count
1000-1200 4
800-1000 2
1200-1400 1
1400-1600 1
200-400 1
400-600 1

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


 

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

Average head coach salary by division

Friday, December 23, 2022

Data Analysis, Python, Pandas, Data Manipulation, Data Visualization, External Dataset, InterviewQs Average head coach salary by division Data Analysis Python Pandas Data Manipulation Data

Convert romain numeral strings to integer outputs

Wednesday, December 21, 2022

Python, Algorithms, Data Structures, InterviewQs Convert romain numeral strings to integer outputs Python Algorithms Data Structures Forward this email to a friend or colleague and challenge them to

Describe the main assumptions of linear regression

Monday, December 19, 2022

Linear Regression, Statistics, Machine Learning, InterviewQs Describe the main assumptions of linear regression Linear Regression Statistics Machine Learning Forward this email to a friend or colleague

Describe the purchase value of a user

Friday, December 16, 2022

Data Analysis, Python, Pandas, Data Manipulation, Data Visualization, External Dataset, InterviewQs Describe the purchase value of a user Data Analysis Python Pandas Data Manipulation Data

Finding the intersection of arrays

Monday, December 12, 2022

Python, Data Structures, Algorithms, InterviewQs Finding the intersection of arrays Python Data Structures Algorithms Forward this email to a friend or colleague and challenge them to solve it. Hi,

You Might Also Like

Power BI Weekly #256 - 1st May 2024

Wednesday, May 1, 2024

Power BI Weekly Newsletter Issue #256 powered by endjin Welcome to the 256th edition of Power BI Weekly! No announcements this week, so we'll jump straight into the highlighted articles. Firstly,

Apple AI browser 🌎, Tesla fires Supercharger team ⚡,  new sudo replacement 👨‍💻

Wednesday, May 1, 2024

Apple is testing a version of its Safari web browser that includes an AI-powered tool called Intelligent Search Sign Up |Advertise|View Online TLDR Together With Modern Treasury TLDR 2024-05-01 The

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