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
- #46A streaming platform wants to identify content that's experiencing 'viewership...medium
- #55AdMetrics Agency manages digital advertising campaigns across multiple channelsmedium
- #56TelecomCorp wants to analyze call quality degradation patterns across their cell...medium
- #41You're analyzing user engagement for a social media platformeasy
- #42A video streaming platform tracks user viewing sessionshard
← Back homemockbit.io/q/57