Back to questions

FAANG Underperforming Stocks (Part 3) Salesforce SQL Interview Question

FAANG Underperforming Stocks (Part 3)

Salesforce SQL Interview Question

As a trading analyst at Bloomberg, your task is to identify specific months when a majority of the FAANG stocks (Facebook, Amazon, Apple, Netflix, Google) experienced a gain in value compared to the previous month, while one stock lagged behind its peers by recording a decrease in value. This analysis involves comparing opening prices from the previous month.

In essence, you're seeking months where 5 out of 6 FAANG stocks demonstrated an increase in value with one stock experiencing a decline.

Write a query to display the month and year in 'Mon-YYYY' format along with the ticker symbol of the stock that underperformed relative to its peers, ordered by month and year (in 'Mon-YYYY' format).

Schema:

Column NameTypeDescription
datedatetimeThe specified date (mm/dd/yyyy) of the stock data.
tickervarcharThe stock ticker symbol (e.g., AAPL) for the corresponding company.
opendecimalThe opening price of the stock at the start of the trading day.
highdecimalThe highest price reached by the stock during the trading day.
lowdecimalThe lowest price reached by the stock during the trading day.
closedecimalThe closing price of the stock at the end of the trading day.

Example Input:

Note that the table below displays data in June and July 2023.

datetickeropenhighlowclose
datetickeropenhighlowclose
06/30/2023 00:00:00AAPL191.26191.63194.48193.97
06/30/2023 00:00:00GOOG123.50129.55116.91120.97
06/30/2023 00:00:00AMZN120.69131.49119.93130.36
06/30/2023 00:00:00META265.90289.79258.88286.98
06/30/2023 00:00:00MSFT325.93351.47322.50340.54
06/30/2023 00:00:00NFLX397.41448.65393.08440.49
07/31/2023 00:00:00AAPL195.26196.06196.49196.45
07/31/2023 00:00:00GOOG120.32134.07115.83133.11
07/31/2023 00:00:00AMZN130.82136.65125.92133.68
07/31/2023 00:00:00META286.65326.11284.85318.60
07/31/2023 00:00:00MSFT339.19366.78327.00335.92
07/31/2023 00:00:00NFLX439.76485.00411.88438.97

Example Output:

mth_yrunderperforming_stock
Jul-2023GOOG

In July 2023, the GOOG stock underperformed relative to the other five FAANG stocks which is exhibited by comparing their opening prices in June 2023. The remaining FAANG stocks performed better in July 2023, except for GOOG which experienced a decline in value.

The dataset you are querying against may have different input & output - this is just an example!

Input

Output