> For the complete documentation index, see [llms.txt](https://docs.pinot.apache.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.pinot.apache.org/release-1.1.0/configuration-reference/functions/stdistance.md).

# ST\_Distance

For geometry type, returns the 2-dimensional cartesian minimum distance (based on spatial ref) between two geometries in projected units. For geography, returns the great-circle distance in meters between two SphericalGeography points. Note that g1, g2 shall have the same type.

## Signature

> ST\_Distance(geography/geometry, geography/geometry)

## Usage Examples

These examples are based on the [Streaming Quick Start](/release-1.1.0/basics/getting-started/quick-start.md#streaming).

```sql
select group_city, 
       STASTEXT(location) AS locationString, 
       ST_Distance(location, ST_POINT(2.154007,41.390205, 1)) AS distanceInMetres
from meetupRsvp 
LIMIT 1
```

| group\_city | locationString      | distanceInMetres  |
| ----------- | ------------------- | ----------------- |
| Madrid      | POINT (-3.71 40.42) | 504376.5534398629 |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.pinot.apache.org/release-1.1.0/configuration-reference/functions/stdistance.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
