Practice Interview Questions
| Question | Status |
|---|---|
Assume you're given a table called measurements with measurement values from a Google sensor over multiple days.
Write a SQL query to calculate the sum of odd-numbered and even-numbered measurements separately for a particular day. The resulting table should have 3 columns: measurement_day, odd_sum, and even_sum.
Assumptions:
measurements table:
| Column Name | Description |
|---|---|
| measurement_id | Unique identifier for each measurement |
| measurement_value | The value recorded by the Google sensor |
| measurement_time | Time when the measurement was taken |
| day | odd_numbers | even_numbers |
|---|---|---|
| 2022-06-01 00:00:00 | 5 | 4 |
| 2022-06-02 00:00:00 | 2 | 1 |
| 2022-06-03 00:00:00 | 5 | 5 |
Assume you're given a table called measurements with measurement values from a Google sensor over multiple days.
Write a SQL query to calculate the sum of odd-numbered and even-numbered measurements separately for a particular day. The resulting table should have 3 columns: measurement_day, odd_sum, and even_sum.
Assumptions:
measurements table:
| Column Name | Description |
|---|---|
| measurement_id | Unique identifier for each measurement |
| measurement_value | The value recorded by the Google sensor |
| measurement_time | Time when the measurement was taken |
| day | odd_numbers | even_numbers |
|---|---|---|
| 2022-06-01 00:00:00 | 5 | 4 |
| 2022-06-02 00:00:00 | 2 | 1 |
| 2022-06-03 00:00:00 | 5 | 5 |