# Limiting result to the first row returned in query

**URL:** <https://forum.inductiveautomation.com/t/limiting-result-to-the-first-row-returned-in-query/73598>\
**Category:** General Discussion\
**Tags:** scripting, perspective\
**Created:** [May 11, 2023, 3:27pm UTC](https://forum.inductiveautomation.com/t/limiting-result-to-the-first-row-returned-in-query/73598 "2023-05-11T15:27:08Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Javontez\_Robinson](https://avatars.discourse-cdn.com/v4/letter/j/5f9b8f/32.png) [@Javontez\_Robinson](https://forum.inductiveautomation.com/u/Javontez_Robinson)\
**Post date:** [May 11, 2023, 3:27pm UTC](https://forum.inductiveautomation.com/t/limiting-result-to-the-first-row-returned-in-query/73598/1 "2023-05-11T15:27:08Z")

</div>

I have a SQL statement that I want to linit my results to the top row of returned data, but I am getting an error.

SELECT \* FROM BACON\_ASSEMBLY\_LOG with (nolock)  
Where StationID = '137'  
order by StartTimeStamp desc  
Fetch fetch next 3 rows only

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [May 11, 2023, 3:38pm UTC](https://forum.inductiveautomation.com/t/limiting-result-to-the-first-row-returned-in-query/73598/2 "2023-05-11T15:38:09Z")

</div>

Depends on the type of database. Some have you put `TOP 3` right after `SELECT`, others have you put `LIMIT 3` at the end.

---

<div class="post-metadata">

**Author:** ![Javontez\_Robinson](https://avatars.discourse-cdn.com/v4/letter/j/5f9b8f/32.png) [@Javontez\_Robinson](https://forum.inductiveautomation.com/u/Javontez_Robinson)\
**Post date:** [May 11, 2023, 4:18pm UTC](https://forum.inductiveautomation.com/t/limiting-result-to-the-first-row-returned-in-query/73598/3 "2023-05-11T16:18:51Z")

</div>

The Data query browser is where I am writing the query. so, would that be Select Top

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [May 11, 2023, 4:22pm UTC](https://forum.inductiveautomation.com/t/limiting-result-to-the-first-row-returned-in-query/73598/4 "2023-05-11T16:22:53Z")

</div>

It depends _on the type of database_. MySQL, MSSQL, PostgreSQL, Oracle, SQLite, etc.
