Ok. First let me apologize profusely if this question has been covered. I did look but none of the solutions addressed the particulars of my problem.
I have a table of over 160 million rows of data tracking employee/server conditions over time. I want to create a subset of this data and remove the repetition that occurs throughout, BUT keeps the sequence of changes as they occur. The reduction for most employees would be from 700 rows (and growing) to 1.
Here’s a simplified example of what I’m trying to get to:
Given:
RowID Employee Server Timestamp
----- -------- ------ ---------
5 E000001 Serv-B May01
4 E000001 Serv-A Apr01
3 E000001 Serv-B Mar01
2 E000001 Serv-A Feb01
1 E000001 Serv-A Jan01
Doing a "Min(Timestamp) Group By Employee, Server" would yield:
Employee Server Timestamp
-------- ------ ---------
E000001 Serv-B Mar01
E000001 Serv-A Jan01
.
What I need is:
Employee Server Timestamp
-------- ------ ---------
E000001 Serv-B May01
E000001 Serv-A Apr01
E000001 Serv-B Mar01
E000001 Serv-A Jan01
The table and the process that feeds it do not belong to our group so I can’t affect a solution there and I’d rather not be stuck with a copy of the entire thing. I can’t realistically do a cursor/RBAR approach given the size of the table. If backed into a corner, I can write an application program to do this but I was wondering if any of the gods from SQoLympus had any wisdom for doing this in a stored procedure. Thanks in advance!
Edit: It’s SQL Server 2008 – Sorry for not mentioning it.
If SQL Server (assuming I have understood your requirements correctly)