Subway data Columns:
- Station_id (1,2,3,4,5,6,7,8,1,2,3,4,5,1,2,3,4,5,6,7,1,2,3)
- Number of people boarded
- Number of people deboarded
- Occupancy
Occupancy at current station = Number of people already in the train at previous station + Number of people boarded - Number of people deboarded
I am trying to fill the occupancy column. The issue is that the dataset is for multiple subway trains so station_id changes back to 1 and on that station number of people deboarded is always 0 since it is the station from which train journey begins. I have got no clue on how to do this in postgresql. The occupancy column in the sample image below is empty and needs to be filled