SQL select Query for report building

I have a table generated from transaction group tags that writes a new line in the table every time its triggered. I’m trying to build a report table that will list every row from the last 24hrs. I’ve tried several variations of the following code but haven’t had success yet.

SELECT t_stamp, ProdStr, Total_panels_per_ShiftOrRun, RunEfficency, VolumeSumof38
FROM mdo_report
t_stamp >= now({[System]Gateway/CurrentDateTime}) AND
t_stamp <= DATE_SUB(now({[System]Gateway/CurrentDateTime}),INTERVAL 24 HOUR)

At a quick glance, you’re using an ORDER BY when it should be a WHERE clause, and also limiting your return to 10 records.

Thanks for the quick response, I still haven’t been able to reach my desired result. For context, this is ultimately what I’m trying to accomplish. I have a table in a vision window that updates on a trigger, adding a new row and I’m trying to create a report that looks like this table. In the vision window I used that data range component instead of the appropriate scripting.
I didn’t think I’d have to add a new data source for every row in the report builder but I ay need to resort to that if I cant sort this scripting out.

Also, when I do post this table in the report build, it only shows one row. I must be missing something simple here. If its relevant, the table is an automatically generated one from a transaction group.

Do you have your start and end dates reversed?
should be t_stamp >= the Date Subtract 24 hours and t_stamp <= now

1 Like