Support Forums
SQL query syntax

Hello, I'm querying values data from VTScada's SQL View tag. I've set up my SQL View tag to include 2 analog tags that store the previous day's total flow for their respective meters. This data updates at midnight each day. The data stored in the tags is always 1 day off.

I'd like for the SQL query to return the values as stored at 08:00:00 each day of the previous calendar month. Also I need to offset the timestamp to subtract 1 day.

This is what I've done so far, though this isn't going to work as I need. Any direction would be greatly appreciated!

SELECT
     TIMESTAMP,
     METER1\PREV_DAY_TOT,
     METER2\PREV_DAY_TOT
FROM FLOWS_1D
WHERE TIMESTAMP BETWEEN '2023-06-01 08:00:00' AND '2023-07-01 08:01:00'
ORDER BY TIMESTAMP DESC LIMIT 31

Thanks!
Tom

Hello, I'm querying values data from VTScada's SQL View tag. I've set up my SQL View tag to include 2 analog tags that store the previous day's total flow for their respective meters. This data updates at midnight each day. The data stored in the tags is always 1 day off. I'd like for the SQL query to return the values as stored at 08:00:00 each day of the previous calendar month. Also I need to offset the timestamp to subtract 1 day. This is what I've done so far, though this isn't going to work as I need. Any direction would be greatly appreciated! ```` SELECT TIMESTAMP, METER1\PREV_DAY_TOT, METER2\PREV_DAY_TOT FROM FLOWS_1D WHERE TIMESTAMP BETWEEN '2023-06-01 08:00:00' AND '2023-07-01 08:01:00' ORDER BY TIMESTAMP DESC LIMIT 31 ```` Thanks! Tom
45
0
1
live preview
enter atleast 10 characters
WARNING: You mentioned %MENTIONS%, but they cannot see this message and will not be notified
Saving...
Saved
With selected deselect posts show selected posts
All posts under this topic will be deleted ?
Pending draft ... Click to resume editing
Discard draft