Data Interview Qs - Flagging increasing stock prices in SQL

InterviewQs

Flagging increasing stock prices in SQL

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 table showing closing prices for a stock, cut by date:


Table: Prices

Date ClosingPrice
2020-01-31 00:00:00 52.01
2020-02-01 00:00:00 53.4
2020-02-02 00:00:00 55.23
2020-02-03 00:00:00 54.2
2020-02-04 00:00:00 56.2
2020-02-05 00:00:00 55.12
2020-02-06 00:00:00 55.88
2020-02-07 00:00:00 55.5
2020-02-08 00:00:00 59.33
2020-02-09 00:00:00 59.12
2020-02-10 00:00:00 53.09

Using this table, write a SQL query to calculate 3 and 5-day moving averages. Then, add 2 more columns to flag when a given closing price is over the 3 or 5-day moving average.

You can view/query the table in a db-fiddle here.


 

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

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,

Happiness score correlation

Wednesday, March 16, 2022

Python, Arrays, Data Structures, Statistics, InterviewQs Happiness score correlation Python Arrays Data Structures Statistics Forward this email to a friend or colleague and challenge them to solve it.

Maximum revenue from a given ID

Monday, March 14, 2022

SQL, Database Querying, InterviewQs Maximum revenue from a given ID SQL Database Querying Forward this email to a friend or colleague and challenge them to solve it. Hi, Suppose you're given the

Random dog arrivals

Friday, March 11, 2022

Statistics, Probability Theory, Poisson, InterviewQs Random dog arrivals Statistics Probability Theory Poisson Forward this email to a friend or colleague and challenge them to solve it. Hi, Suppose

Picking a bike lock

Thursday, March 10, 2022

Python, Arrays, Data Structures, Algorithms, InterviewQs Picking a bike lock Python Arrays Data Structures Algorithms Forward this email to a friend or colleague and challenge them to solve it. Hi,

You Might Also Like

Stripe makes more changes

Thursday, April 25, 2024

TikTok is in trouble, and net neutrality is back View this email online in your browser By Christine Hall Thursday, April 25, 2024 Welcome back to TechCrunch PM, your home for all things startups,

💎 Issue 414 - From a Lorry Driver to Ruby on Rails Developer at 38

Thursday, April 25, 2024

This week's Awesome Ruby Newsletter Read this email on the Web The Awesome Ruby Newsletter Issue » 414 Release Date Apr 25, 2024 Your weekly report of the most popular Ruby news, articles and

💻 Issue 414 - JavaScript Features That Most Developers Don’t Know

Thursday, April 25, 2024

This week's Awesome Node.js Weekly Read this email on the Web The Awesome Node.js Weekly Issue » 414 Release Date Apr 25, 2024 Your weekly report of the most popular Node.js news, articles and

💻 Issue 407 - The Performance Impact of C++'s `final` Keyword

Thursday, April 25, 2024

This week's Awesome .NET Weekly Read this email on the Web The Awesome .NET Weekly Issue » 407 Release Date Apr 25, 2024 Your weekly report of the most popular .NET news, articles and projects

💻 Issue 414 - Everyone Has JavaScript, Right?

Thursday, April 25, 2024

This week's Awesome JavaScript Weekly Read this email on the Web The Awesome JavaScript Weekly Issue » 414 Release Date Apr 25, 2024 Your weekly report of the most popular JavaScript news, articles

📱 Issue 408 - All web browsers on iOS are just Safari with different design

Thursday, April 25, 2024

This week's Awesome iOS Weekly Read this email on the Web The Awesome iOS Weekly Issue » 408 Release Date Apr 25, 2024 Your weekly report of the most popular iOS news, articles and projects Popular

💧 Don't Bother Liquid Cooling Your AMD CPU — Why You Should Keep Using Live Photos on iPhone

Thursday, April 25, 2024

Also: We review the Unistellar Odyssey iPhone Telescope, and More! How-To Geek Logo April 25, 2024 Did You Know Charles Darwin and Abraham Lincoln were both born on the same day: February 12, 1809. 💻

💻 Issue 332 - 🥇The first framework that lets you visualize your React/NodeJS app 🤯

Thursday, April 25, 2024

This week's Awesome React Weekly Read this email on the Web The Awesome React Weekly Issue » 332 Release Date Apr 25, 2024 Your weekly report of the most popular React news, articles and projects

💻 Issue 409 - Sized, DynSized, and Unsized by Niko Matsakis

Thursday, April 25, 2024

This week's Awesome Rust Weekly Read this email on the Web The Awesome Rust Weekly Issue » 409 Release Date Apr 25, 2024 Your weekly report of the most popular Rust news, articles and projects

📱 Issue 411 - AI Starts to Sift Through String Theory's Near-Endless Possibilities

Thursday, April 25, 2024

This week's Awesome Swift Weekly Read this email on the Web The Awesome Swift Weekly Issue » 411 Release Date Apr 25, 2024 Your weekly report of the most popular Swift news, articles and projects