How would you write a SQL query to find duplicate product listings across multiple retail store locations?
Assume duplicate listings are active listings for the same product appearing at two or more distinct store locations. Return only products with valid product and store records.
product_id, product_name, brand, location_count, and locations.location_count descending, then product_id ascending.| Column | Type | Description |
|---|---|---|
| listing_idPK | INTEGER | Unique listing identifier |
| product_id | INTEGER | Referenced product identifier |
| store_id | INTEGER | Referenced retail store identifier |
| listing_status | VARCHAR(20) | Listing state, such as active or inactive |
| Column | Type | Description |
|---|---|---|
| store_idPK | INTEGER | Unique retail store identifier |
| store_name | VARCHAR(120) | Retail store name |
| city | VARCHAR(80) | Store city |
| Column | Type | Description |
|---|---|---|
| product_idPK | INTEGER | Unique product identifier |
| product_name | VARCHAR(150) | Product display name |
| brand | VARCHAR(100) | Product brand |