user2268507
user2268507

Reputation:

SQL Apache Derby - Select last value in column

I am using Apache Derby and am trying to select the last value in a column.

Currently I have the following:

SELECT id FROM hotels ORDER BY id DESC WHERE ROWNUM <=1;

However this is resulting in a syntax error:

Syntax error: Encountered "WHERE" at line 1, column 44.

Would anyone know the proper way to write this query?

Thank you.

Upvotes: 0

Views: 607

Answers (1)

Gordon Linoff
Gordon Linoff

Reputation: 1269733

The order by clause goes after the where. Perhaps you intend:

SELECT MAX(id)
FROM hotels;

Upvotes: 1

Related Questions