Teradata SQL query to find sum of fields with same column values -


i stuck 1 task. have table this

departure | arrival    | sum  aaa      | zzz        | 100  zzz      | aaa        | 50  aaa      | ccc        | 60 

i want sum of same routes , condition here should treat aaa-zzz , zzz-aaa route 1 route. route zzz-aaa it's route original destination.

i'm trying obtain result this:

departure | arrival    | sum  aaa      | zzz        | 150  aaa      | ccc        | 60 

any suggestions, ideas please on how can write sql query achieve ?

regards, jack

just use least() , greatest():

select least(departure, arrival) departure,        greatest(departure, arrival) arrival,        sum(al) t group least(departure, arrival),          greatest(departure, arrival); 

Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -