On an every minute interval, I would like to consolidate values in my SQL table to compress space. If I have a table with values such as:
UserId Value Date
1 2 10/08/2010 10:30:00
1 2 10/08/2010 10:30:10
1 2 10/08/2010 10:30:20
1 2 10/08/2010 10:30:30
1 2 10/08/2010 10:30:40
1 2 10/08/2010 10:30:50
1 2 10/08/2010 10:31:00
1 2 10/08/2010 10:31:10
1 2 10/08/2010 10:31:20
1 2 10/08/2010 10:31:30
1 2 10/08/2010 10:31:40
1 2 10/08/2010 10:31:50
Every minute, I would like to compress values into single minute intervals. So the top table would look like:
UserId Value Date
1 12 10/08/2010 10:30:00
1 12 10/08/2010 10:31:00
...after thh query had been run. The previous values would be removed and replaced by the new consolidated values.
How can I accomplish this in TSQL?