How do I go about retrieving the records only when a change in the datacolumn 'Aux1' is detected? Example, here is a table with some dataID | Timesecs | Aux1-------------------- 1 | 51111111 | ON 2 | 51111112 | ON 3 | 51111113 | ON 4 | 51111114 | OFF 5 | 51111115 | OFF 6 | 51111116 | ON 7 | 51111117 | ON 8 | 51111118 | ON 9 | 51111119 | OFF10 | 51111120 | OFF11 | 51111121 | OFFetc....The results from the records I retrieve should look like this:ID | Timesecs | Aux1-------------------- 1 | 51111111 | ON 4 | 51111114 | OFF 6 | 51111116 | ON 9 | 51111119 | OFFetc....CREATE TABLE #temp (id int IDENTITY, timesecs int, Aux1 char(4))INSERT INTO #temp VALUES ('5111111', 'ON')INSERT INTO #temp VALUES ('5111112', 'ON')INSERT INTO #temp VALUES ('5111113', 'ON')INSERT INTO #temp VALUES ('5111114', 'OFF')INSERT INTO #temp VALUES ('5111115', 'OFF')INSERT INTO #temp VALUES ('5111116', 'ON')INSERT INTO #temp VALUES ('5111117', 'ON')INSERT INTO #temp VALUES ('5111118', 'ON')INSERT INTO #temp VALUES ('5111119', 'OFF')INSERT INTO #temp VALUES ('5111120', 'OFF')INSERT INTO #temp VALUES ('5111121', 'OFF')SELECT * FROM #tempDROP TABLE #temp
Jose