Skip to content
Advertisement

Simplifying SQL query

I’m using the Bixi public dataset found at https://www.bixi.com/en/open-data and have been asked to find “the average number of trips a day for each year-month combination in the dataset”. Here’s an example of the table from which I’m querying:

id start_date start_station_code end_date end_station_code duration_sec is_member
85843 2016-04-15 00:00:00 6315 2016-04-15 00:05:00 6315 349 1
85844 2016-04-15 17:16:00 6315 2016-04-15 17:37:00 6315 1293 0

The query that I used to successfully answer the question was as follows, but how can I simplify it?:

Advertisement

Answer

Use conditional aggregation:

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement