thank you.i have an additional column the table change to beadditional columneventtime parameter001 value001 quality001 2012-01-11 00:05:00.0000000 a 0 good2012-01-11 00:06:00.0000000 a 1 good2012-01-11 00:07:00.0000000 a 1 good2012-01-11 00:08:00.0000000 a 0 bad2012-01-11 00:09:00.0000000 a 0 goodthe resulteventtime parameter value2012-01-11 00:06:00.0000000 a 12012-01-11 00:09:00.0000000 a 0 i try;with cteas (select *, row_number() over(order by EventTime) rnfrom events where quality001 <> 'BAD')
it work finebut i need to keep the "BAD Value" in cte query. How can i make condition to query only "GOOD" in the second query( the query that query from cte)about datediffi test this select DATEDIFF(mi,a.eventtime,b.eventtime) tRangefrom (select ROW_NUMBER() over(order by eventtime) rr,* from tt where value001 = 1) ainner join (select ROW_NUMBER() over(order by eventtime) rr, * from tt where value001 = 0) bon a.rr = b.rr
this query is correct or not? if i want range from the pair of active and inactive.tt table is that table dump the second query to it(for test query).my question is how can i reference to the last query(the query from cte).how to wrap all this part of queryselect b.EventTime, b.parameter001, b.value001from cte ainner join cte b on a.rn + 1 = b.rn and a.value001 <> b.value001union allselect b.EventTime, b.parameter002, b.value002from cte ainner join cte b on a.rn + 1 = b.rn and a.value002 <> b.value002union allselect b.EventTime, b.parameter003, b.value003from cte ainner join cte b on a.rn + 1 = b.rn and a.value003 <> b.value003
and make a reference to the next querythank you for any advice again and really thank for Bustaz Kool