InMobi campaign reporting combines campaign records with their associated advertisers. Write a PostgreSQL query that joins these two tables and returns the campaign name and advertiser name twice: first in ascending campaign-name order, then in descending campaign-name order.
Requirements
- Join
inmobi_campaigns to inmobi_advertisers using the advertiser identifier.
- Return only campaigns with a matching advertiser.
- Produce one ascending result block followed by one descending result block.
- Place NULL campaign names last within either sort direction, while retaining matched rows with NULL advertiser names.
Output details
- Return columns named
campaign_name followed by advertiser_name.
- Within the ascending block, sort ties by
advertiser_name ascending with NULLs last.
- Within the descending block, sort ties by
advertiser_name descending with NULLs last.
- Use
campaign_id ascending as the final tie-breaker in both blocks.
- Preserve duplicate matched rows without deduplication.