Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
SQL for Options Average Price
00:00
5 left

SQL for Options Average Price

EasySQL · PostgreSQL

Problem

Write a SQL query to find the average price of options traded in the last month.

Use the previous calendar month relative to CURRENT_DATE and exclude trades without a valid option contract or price.

Output

  1. Return one row with one column, average_price.
  2. Include only qualifying option trades from the previous calendar month.
  3. No specific ordering is required.

Schema

option_trades
ColumnTypeDescription
trade_idPKINTUnique identifier for the trade
option_idINTReferenced option contract identifier
traded_atTIMESTAMPTimestamp when the option was traded
trade_priceNUMERIC(12,4)Price paid for the option trade
option_contracts
ColumnTypeDescription
option_idPKINTUnique identifier for the option contract
option_symbolVARCHAR(20)Market symbol for the option
option_typeVARCHAR(4)Option type, CALL or PUT
strike_priceNUMERIC(12,2)Contract strike price
Tablesoption_tradesoption_contracts
Interviewer

Your question is SQL for Options Average Price. Start with the requirements and the two tables in the Question tab.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.
CodePostgreSQL
You need to log in / sign up to run or submit.Ln 1
Run your query to see results here.