I am dealing with some graph related data, which has directional to-from nodes. This is the initial mock data.
However, I am trying to analyse it as unidirectional path. This means that I will somehow need to swap some of the rows of node1 with node2 to do a group by. Like below.
Does anyone know how to write an SQL query for this? Thanks!
heres the mock initial data in comma delimited.
You apparently want the smaller value to be node1. This can be done using the
select id, least(node1, node2) as node1, greatest(node1, node2) as node2, "count" from the_table;