Only this week, get the SQL Complete Track of 9 courses in a special prize of $330 $89!
10. ST_X, ST_Y


Excellent. We already mentioned that a point represents a single location on Earth. It has a shape and length of 0. This has both its advantages and disadvantages. On one hand, points take up very little space in spatial databases. Calculations performed with points are also quick. On the other hand, we can't precisely define the shapes of objects represented with points. They are therefore suitable representations of simple objects whose shape does not matter to us, such as tram stops, ATMs, post boxes or road signs.

At this point in the course, it is worth getting to know two functions that can be used to work with points: ST_X(geometry) and ST_Y(geometry). These functions return the X and Y coordinates, respectively, of a point.

FROM sf_atms;

The above query will return the X coordinates (longitudes) of all ATMs in San Francisco.


For each tram stop with possible changes to other lines, show the coordinates as WKT, then the latitude, and then the longitude.

Stuck? Here's a hint!

Use those three functions in the SELECT clause: ST_AsText, ST_X, ST_Y.