brianpacitti

Query to return value immediately before a time

Discussion created by brianpacitti on Jul 22, 2009
Latest reply on Jul 29, 2009 by brianpacitti

Hi,

 

What I'm trying to do seems simple and as such I'm sure there is a real simple way to do this.

 

This is the query I have at the moment.

SELECT TOP 1 value, time 
FROM piarchive..picomp2
WHERE tag = 'sinusoid'
  AND time <= '27/05/2009 15:05:06' ORDER BY time DESC

What I'm trying to achieve is selecting the value of sinusoid immediately before the time specified. The query above was working on the development environment but then stopped working. The error is "Event collection exceeded the maximum allowed". Looking at the query this makes sense as it will be returning loads of data.

 

What would be the recommended way to achieve this?

 

Thanks.

Outcomes