Reputation: 81
Working with the professional mobility of insee on more than 1m of entities, i seek to add up a field called ipondi only on the journeys from commune of residence to commune of work, and not of commune of work to residential commune.
Let us assume a simple example, with the column of commune of residence named "departure", and commune of work named "arrival", and the field which i wish to make the sum named "ipondi":
start; end; ipondi
La Ciotat; Marseille; 84
La Ciotat; Marseille; 15
Aubagne; Ceyreste; 12
Marseille; La Ciotat; 73
So I get the following result:
select start, end, sum(ipondi)
from trajets
group by start, end
So I get the following result:
La Ciotat; Marseille; 99
Aubagne; Ceyreste; 12
Marseille; La Ciotat; 73
Which is normal. However, I would like to "delete" the Marseille; La Ciotat because it is the return journey of the first two lines. This being so to arrive at this result:
start; end; ipondi
La Ciotat; Marseille; 99
Aubagne; Ceyreste; 12
My link to my database : https://drive.google.com/file/d/1TOB1MTAt8UNCjt0up6qcgnR593yMXkqt/view?usp=sharing
How to do this on PostgreSQL?
Thank you.
Upvotes: 0
Views: 31