declare @dt datetimeselect top 1 @dt=timestamp from ihRawData t
where tagname=mytage
      and timestamp>='25-10-2005 09:30:00' 
      and timestamp<='26-10-2005 00:00:00'
      and value<>0
order by timestamp
select timestamp from ihRawData t
where tagname=mytage
      and timestamp>='25-10-2005 09:30:00' 
      and timestamp<='26-10-2005 00:00:00'
      and value<>0
      and datediff(second,@dt,t.timestamp)%5=0
order by timestamp