
You are given a small schema that models entities, alerts, and analyst investigations in a Foundry-style operational dataset. Write a PostgreSQL query that returns each entity created in January 2024 that has alerts from at least two distinct sources and at least one open investigation. For each qualifying entity, return the entity name, the number of distinct alert sources, the total number of alerts in January 2024, and a priority label of high when the entity has 3 or more January alerts, otherwise medium.
Because you do not have a running database, you should reason from the schema and sample data and produce the exact result set shown below.