Given a table of restaurant sales, write a SQL query to calculate daily revenue by store and rank the top 3 stores for each day.
Use the provided sales table. Include stores with non-null sales records, treat null sale amounts as zero when calculating revenue, and break revenue ties by ascending store ID.
sale_date, store_id, daily_revenue, and store_rank.sale_date ascending, then store_rank ascending.| Column | Type | Description |
|---|---|---|
| sale_idPK | INTEGER | Unique identifier for a sale |
| sale_date | DATE | Date on which the sale occurred |
| store_id | INTEGER | Identifier of the restaurant store |
| sale_amount | NUMERIC(10,2) | Revenue amount for the sale |