logo

Back to questions

FAANG Stock Min-Max (Part 1) [Bloomberg SQL Interview Question]

Medium

The Bloomberg terminal is the go-to resource for financial professionals, offering convenient access to a wide array of financial datasets. As a Data Analyst at Bloomberg, you have access to historical data on stock performance.

Currently, you're analyzing the highest and lowest open prices for each FAANG stock by month over the years.

For each FAANG stock, display the ticker symbol, the month and year ('Mon-YYYY') with the corresponding highest and lowest open prices (refer to the Example Output format). Ensure that the results are sorted by ticker symbol.

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 randomly selected AAPL data.

datetickeropenhighlowclose
01/31/2023 00:00:00AAPL142.28142.70144.34144.29
02/28/2023 00:00:00AAPL146.83147.05149.08147.41
03/31/2023 00:00:00AAPL161.91162.44165.00164.90
04/30/2023 00:00:00AAPL167.88168.49169.85169.68
05/31/2023 00:00:00AAPL176.76177.33179.35177.25

Example Output:

tickerhighest_mthhighest_openlowest_mthlowest_open
AAPLMay-2023176.76Jan-2023142.28

Apple Inc. (AAPL) achieved its highest opening price of $176.76 in May 2023 and its lowest opening price of $142.28 in January 2023.

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

PostgreSQL 14