sql - Calculating parking spot usage in percentages using PostgreSQL -


i'm working on project getting real-time data parking spot sensors , save parking events database.

currently 1 of database tables

| starttime              | endtime                 | parkingspotid '2017-09-12 13:50:20.04' | '2017-09-12 13:56:20.04'| 1 '2017-09-12 14:50:24.04' | '2017-09-12 14:51:20.04'| 2 '2017-09-12 14:50:50.04' | '2017-09-12 14:59:20.04'| 1 

how go using generate_series make query output each hour, usage percentage across parking spots, based on percentages of time within hour, cars parked eg. 2pm - 3pm car might parked 30 mins

output this

| time                   | percentage  '2017-09-12 00:00:00.00' | 54 '2017-09-12 01:00:00.00' | 43 '2017-09-12 02:00:00.00' | 45 '2017-09-12 03:00:00.00' | 64 '2017-09-12 04:00:00.00' | 76 


Comments

Popular posts from this blog

neo4j - finding mutual friends in a cypher statement starting with three or more persons -

php - How to remove letter in front of the word laravel -

minify - Minimizing css files -