Mockbit/#57
SQLmediumCtes~16m

A hedge fund tracks daily portfolio performance across multiple trading...

Problem

A hedge fund tracks daily portfolio performance across multiple trading strategies. They want to identify which portfolios had consecutive days of losses (negative daily returns) of 3 or more days, and for those portfolios, calculate the total loss amount during their longest consecutive losing streak. Include the portfolio details, streak start/end dates, streak length, and total loss amount. Only include portfolios that actually experienced a streak of 3+ consecutive loss days.

Examples

Example 1

Example 2

Constraints
  • Return columns: portfolio_name, strategy_type, fund_manager, streak_start_date, streak_end_date, streak_length_days, total_loss_amount
  • Only include portfolios with 3+ consecutive loss days
  • For each qualifying portfolio, show only their LONGEST consecutive losing streak
  • Loss amount should be positive (absolute value of negative returns)
  • Order by total_loss_amount DESC, then portfolio_name ASC
Reference solution

Reference solution available after you attempt the question.

Ready to solve it?

Start a session on Mockbit #57. Write your SQL, run it against real data, and get graded on correctness, efficiency, query structure, and business understanding.

Related SQL questions
← Back homemockbit.io/q/57
PrivacyTerms© 2026 Mockbit