SQL Scripting For Tables

I am creating an SQL query, I have the the following types of values

image

I would like to filter by the largest "id", I want to only show the top 5 largest "id" values, and display only the eventtime and the source on the table.

My current query that exclusively displays all of the values for each column is below.
image
I had worked on this for a while, but continue to write SQL scripts that yield no data.

What is the database?

For MariaDB/MYSql something like this should work:

SELECT source,eventtime FROM alarm_events ORDER BY id DESC LIMIT 5
1 Like

As @bschroeder suggested. An ORDER BY with a row limit would work. Depending on the DB flavor, the syntax for the row limit will differ. See this page for examples: SQL SELECT TOP, LIMIT, ROWNUM.