There is a database with cities and their coordinates. It is required to display line by line distances between all cities WITHOUT repetitions.
Approximate base
CITY_NAME COORD_X COORD_Y City1 5 10 City2 20 30 City3 50 70
The distance, for example, is calculated using the formula COORD_X1 - COORD_X2 . Similarly for COORD_Y.
Note that the line with the distance from City1 to City2 is the SAME line, as is the distance from City2 to City1 . Those. it will not be necessary to display it.
Actually at the output of d. result:
City1-City2 15 20 City1-City3 45 60 City2-City3 30 40
cross joinin SQL), you can cut off repetition and do it yourself forCity1 < City2, the rest, I think, figure it out. - i-one