# syntax error at end of input / incomplete input

Source: https://sqlstreak.com/sql/errors/syntax-error-at-end-of-input · Tested on PostgreSQL 18.6 and SQLite 3.54.1; results generated 2026-11-22.


**Short answer:** The query stops before it's finished: a parenthesis is never closed, a `CASE` has no `END`, or a clause ends in mid-air (`WHERE`, `AND`). Read the end of the query and finish what it opened.

## The exact messages

- PostgreSQL: `ERROR: syntax error at end of input`
- SQLite: `incomplete input`

## How PostgreSQL prints it

```
ERROR:  syntax error at end of input
LINE 3: WHERE city IN ('Austin', 'Denver'
                                         ^
```

## Why it happens

### An unclosed parenthesis

`IN ('Austin', 'Denver'` or `COUNT(*` with no `)`. Count opening and closing brackets; editors highlight the matching pair.

### CASE without END

Every `CASE` needs an `END`, even when there's only one `WHEN`.

### A clause cut off

A query that ends at `WHERE`, `AND` or `ORDER BY`, often after deleting the last condition.

## The broken query

```sql
SELECT name, city
FROM customers
WHERE city IN ('Austin', 'Denver'
```

## The fix

```sql
SELECT name, city
FROM customers
WHERE city IN ('Austin', 'Denver');
```

Close the parenthesis. A trailing semicolon isn't required, but it makes a cut-off query easier to spot.

| name | city |
| --- | --- |
| Maya Ortiz | Austin |
| Jonah Reed | Denver |
| Priya Nair | Austin |
| Ellie Park | Denver |
| Lena Fischer | Austin |
| Diego Santos | Denver |
