# SQL query of only specified rows

**URL:** <https://forum.inductiveautomation.com/t/sql-query-of-only-specified-rows/15718>\
**Category:** Ignition\
**Created:** [October 19, 2017, 5:57pm UTC](https://forum.inductiveautomation.com/t/sql-query-of-only-specified-rows/15718 "2017-10-19T17:57:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![gcampbell](https://avatars.discourse-cdn.com/v4/letter/g/3ab097/32.png) [@gcampbell](https://forum.inductiveautomation.com/u/gcampbell)\
**Post date:** [October 19, 2017, 5:57pm UTC](https://forum.inductiveautomation.com/t/sql-query-of-only-specified-rows/15718/1 "2017-10-19T17:57:26Z")

</div>

Hello all, I am having a little difficulty here. I have to run a daily automated report that pulls data from the previous 24 hour period. The DB records data every minute and I have the below instruction that works great. However, I now have to pull a separate report that only pulls the data for every 30 minutes. Is there a way to adjust this code to only pull the previous days data and only the rows that have the 30 minute data? I hope I am explaining this well enough. Thanks in advance for any assistance.

SELECT CEMS\_DATA\_MIN.DATE\_TIME,  
CEMS\_DATA\_MIN.UNIT\_ID,  
CEMS\_DATA\_MIN.DATA32,  
CEMS\_DATA\_MIN.DATA30  
FROM CEMS\_DATA\_MIN  
WHERE CEMS\_DATA\_MIN.UNIT\_ID = 2154 AND ROWNUM \<= 1440  
ORDER BY CEMS\_DATA\_MIN.DATE\_TIME DESC

---

<div class="post-metadata">

**Author:** ![mrogers](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mrogers/32/4110_2.png) [@mrogers](https://forum.inductiveautomation.com/u/mrogers)\
**Post date:** [October 19, 2017, 9:28pm UTC](https://forum.inductiveautomation.com/t/sql-query-of-only-specified-rows/15718/2 "2017-10-19T21:28:14Z")

</div>

What about adding

```auto
AND ROWNUM % 30 = 0

```

to the where line? Should get row 0, row 30, row 60, etc. And you want just that one line, not some sort of aggregate, right?

---

<div class="post-metadata">

**Author:** ![gcampbell](https://avatars.discourse-cdn.com/v4/letter/g/3ab097/32.png) [@gcampbell](https://forum.inductiveautomation.com/u/gcampbell)\
**Post date:** [October 23, 2017, 4:17pm UTC](https://forum.inductiveautomation.com/t/sql-query-of-only-specified-rows/15718/3 "2017-10-23T16:17:36Z")

</div>

I do actually have to generate a min, max, and average at the bottom of the report.
