SQL Query - First and Last Entry

Using MS SQLExpress, trying to use a single query to get the first and last entry in the table. Could easily do it with two queries, but would like to use one

My two query statements

Select top 1 t_stamp from Data order by t_stamp asc

and

Select top 1 t_stamp from Data order by t_stamp desc

work just fine on their own
image

image

But I get a syntax error when I try to union them
image

Tried using parenthesis around the select statements, but then get an error on the select statement itself.

You have to wrap your two statements into subqueries, because SQL doesn’t allow you to have two independent ORDER BY clauses on the “same” data (the result of your UNION).

Thanks! Works like a charm
image