D
Dave Taylor
I have a database that records elemental analysis numbers from an X-ray
analyzer about once every 60 to 90 seconds, each record includes a record ID
(sequential), timestamp, name of the stream being sampled, and the assay
values. I wrote a query that sorted the table by stream name and timestamp
and then grouped by the stream name and pulled the last() values out for
each stream name. This seemed to work until yesterday, and now the results
are all from January 19th and I *know* there is later data (i.e. I can see
data in the main historian table from just a few minutes ago). I've
attached my SQL query text below and for the life of me cannot figure out
why in the heck it wont pull the latest values. Any help is greatly
appreciated. Is there a better way to achieve this same result?
Also, a bothersome quirk...when I save this query in Access, it always
converts the parenthesis to square brackets on the inner SELECT statement
and then complains about invalid bracketing...yet if I convert it back to
parenthesis, it works just fine (less the problem of not picking up the
LAST() record of the group). To get around this, I did try converting the
inner SELECT to a named query, and that got rid of this issue, however it
still didnt pickup the LAST() record of the group.
Thanks
Dave Taylor
SELECT Historian.stream_name, Last(Historian.timestamp) AS [timestamp],
Last(Historian.fe) AS fe, Last(Historian.pb) AS pb, Last(Historian.zn) AS
zn, Last(Historian.solids) AS solids, Last(Historian.result) AS result,
"PXDetail.aspx?rec_id=" & Format(Last(Historian.rec_id)) AS url
FROM (SELECT * FROM Historian ORDER BY [stream_name], [timestamp]) AS
Historian
GROUP BY Historian.stream_name;
analyzer about once every 60 to 90 seconds, each record includes a record ID
(sequential), timestamp, name of the stream being sampled, and the assay
values. I wrote a query that sorted the table by stream name and timestamp
and then grouped by the stream name and pulled the last() values out for
each stream name. This seemed to work until yesterday, and now the results
are all from January 19th and I *know* there is later data (i.e. I can see
data in the main historian table from just a few minutes ago). I've
attached my SQL query text below and for the life of me cannot figure out
why in the heck it wont pull the latest values. Any help is greatly
appreciated. Is there a better way to achieve this same result?
Also, a bothersome quirk...when I save this query in Access, it always
converts the parenthesis to square brackets on the inner SELECT statement
and then complains about invalid bracketing...yet if I convert it back to
parenthesis, it works just fine (less the problem of not picking up the
LAST() record of the group). To get around this, I did try converting the
inner SELECT to a named query, and that got rid of this issue, however it
still didnt pickup the LAST() record of the group.
Thanks
Dave Taylor
SELECT Historian.stream_name, Last(Historian.timestamp) AS [timestamp],
Last(Historian.fe) AS fe, Last(Historian.pb) AS pb, Last(Historian.zn) AS
zn, Last(Historian.solids) AS solids, Last(Historian.result) AS result,
"PXDetail.aspx?rec_id=" & Format(Last(Historian.rec_id)) AS url
FROM (SELECT * FROM Historian ORDER BY [stream_name], [timestamp]) AS
Historian
GROUP BY Historian.stream_name;