patrussell
Technical User
I have a time based table that is written to every 5 seconds. I need to write a query that will only pull data from the table when one of 3 values has changed. A simple select query is below with a sample of the data.
[tt]
timestamp HF Nit Sulf
2011-01-07 08:51:57.487 17337 10530 3570
2011-01-07 08:51:52.487 17337 10530 3570
2011-01-07 08:51:47.487 17337 10535 3570
2011-01-07 08:51:42.487 17337 10536 3570
2011-01-07 08:51:37.487 17337 10537 3570
2011-01-07 08:51:32.487 17337 10537 3570
[/tt]
What I need returned from this data set is rows 1,3,4,5 since the actual data for each record has changed. With the timestamp changing every five seconds my SQL skills are not good enough to come up with a query that will accomplish this.
I hope I've provided enough information. Thanks for any help you can give.
Pat Russell
Code:
SELECT
timestamp,
ACIDHFTOT_GALS_VAL0 AS HF,
ACIDNITRICTOT_GALS_VAL0 AS Nit,
ACIDSULFTOT_GALS_VAL0 AS Sulf
FROM dbo.ACIDUSAGE
[tt]
timestamp HF Nit Sulf
2011-01-07 08:51:57.487 17337 10530 3570
2011-01-07 08:51:52.487 17337 10530 3570
2011-01-07 08:51:47.487 17337 10535 3570
2011-01-07 08:51:42.487 17337 10536 3570
2011-01-07 08:51:37.487 17337 10537 3570
2011-01-07 08:51:32.487 17337 10537 3570
[/tt]
What I need returned from this data set is rows 1,3,4,5 since the actual data for each record has changed. With the timestamp changing every five seconds my SQL skills are not good enough to come up with a query that will accomplish this.
I hope I've provided enough information. Thanks for any help you can give.
Pat Russell