Categories:

Geospatial functions

ST_Y¶

Returns the latitude (Y coordinate) of a Point represented by a GEOGRAPHY or GEOMETRY object.

Syntax¶

ST_Y( <geography_or_geometry_expression> )
Copy

Arguments¶

geography_or_geometry_expression

The argument must be an expression of the type GEOGRAPHY or GEOMETRY and must contain a Point.

Returns¶

Returns a REAL value.

Usage notes¶

  • Issues an error if the argument is not a Point.

Examples¶

GEOGRAPHY examples¶

This shows a simple use of the ST_X and ST_Y functions with VARCHAR data:

SELECT ST_X(ST_MAKEPOINT(37.5, 45.5)), ST_Y(ST_MAKEPOINT(37.5, 45.5));
+--------------------------------+--------------------------------+
| ST_X(ST_MAKEPOINT(37.5, 45.5)) | ST_Y(ST_MAKEPOINT(37.5, 45.5)) |
|--------------------------------+--------------------------------|
|                           37.5 |                           45.5 |
+--------------------------------+--------------------------------+
Copy

This shows use of the ST_X and ST_Y functions with NULL values:

SELECT
    ST_X(ST_MAKEPOINT(NULL, NULL)), ST_X(NULL),
    ST_Y(ST_MAKEPOINT(NULL, NULL)), ST_Y(NULL)
    ;
+--------------------------------+------------+--------------------------------+------------+
| ST_X(ST_MAKEPOINT(NULL, NULL)) | ST_X(NULL) | ST_Y(ST_MAKEPOINT(NULL, NULL)) | ST_Y(NULL) |
|--------------------------------+------------+--------------------------------+------------|
|                           NULL |       NULL |                           NULL |       NULL |
+--------------------------------+------------+--------------------------------+------------+
Copy