Practice Interview Questions
| Question | Status |
|---|---|
Write a query to identify the top 2 busiest times of the week for the company based on the criteria provided:
Your output should include the day and time of day combination for the 2 busiest times, along with the number of orders. The day should be displayed in text format (e.g. Monday instead of 1). In the event of a tie in ranking, all results should be displayed.
sales_log table:
| Column Name | Description |
|---|---|
| order_id | Unique identifier for each order |
| product_id | Identifier for the product sold |
| timestamp | Time when the sale was made |
Hint: To convert any date to a Day format use:
TO_CHAR(DATE_TRUNC('day', timestamp), 'Day') AS day
| Day | Time of Day | Number of Orders |
|---|---|---|
| Sunday | Late afternoon | 34 |
| Sunday | Morning | 38 |
Write a query to identify the top 2 busiest times of the week for the company based on the criteria provided:
Your output should include the day and time of day combination for the 2 busiest times, along with the number of orders. The day should be displayed in text format (e.g. Monday instead of 1). In the event of a tie in ranking, all results should be displayed.
sales_log table:
| Column Name | Description |
|---|---|
| order_id | Unique identifier for each order |
| product_id | Identifier for the product sold |
| timestamp | Time when the sale was made |
Hint: To convert any date to a Day format use:
TO_CHAR(DATE_TRUNC('day', timestamp), 'Day') AS day
| Day | Time of Day | Number of Orders |
|---|---|---|
| Sunday | Late afternoon | 34 |
| Sunday | Morning | 38 |