> ## Documentation Index
> Fetch the complete documentation index at: /documents/llms.txt
> Use this file to discover all available pages before exploring further.

# ST_X

> Returns the X coordinate of a GEOGRAPHY or GEOMETRY point.

Returns the X coordinate of a point.

For a `GEOGRAPHY` value, X is longitude in degrees under the OGC:CRS84 spherical contract. For a `GEOMETRY` value, X is returned in the units of its declared CRS and is not necessarily longitude. The value must be a non-empty `POINT`.

## Syntax

### Native overloads

```sql theme={null}
DOUBLE ST_X(GEOGRAPHY point)
DOUBLE ST_X(GEOMETRY point)
```

### Legacy overloads

```sql theme={null}
DOUBLE ST_X(VARCHAR point)
```

The argument is a `VARCHAR`-encoded point from a constructor such as [ST\_Point](/documents/4.2/sql-reference/sql-functions/spatial-functions/st_point.md).

## Return value

Returns `NULL` when the input is `NULL`. For native `GEOGRAPHY` and `GEOMETRY`, an empty value or a non-`POINT` family produces an error. Native compute supports XY values with a valid descriptor.

## Examples

### Native examples

```sql theme={null}
SELECT ST_X(ST_GeogFromText('POINT (24.7 56.7)'));
-- 24.7

SELECT ST_X(ST_GeomFromText('POINT (1000000.5 2000000)', 'EPSG:3857'));
-- 1000000.5
```

### Legacy example

```sql theme={null}
SELECT ST_X(ST_Point(24.7, 56.7));
-- 24.7
```

## keyword

ST\_X,ST,X

## Related data types

[GEOGRAPHY](/documents/4.2/sql-reference/data-types/spatial-types/GEOGRAPHY.md), [GEOMETRY](/documents/4.2/sql-reference/data-types/spatial-types/GEOMETRY.md), [VARCHAR](/documents/4.2/sql-reference/data-types/string-type/VARCHAR.md), [DOUBLE](/documents/4.2/sql-reference/data-types/numeric/DOUBLE.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.