POV-Ray : Newsgroups : povray.off-topic : Dr POV-Ray : Re: Dr SQL Server Time
6 Sep 2024 11:16:39 EDT (-0400)
  Re: Dr SQL  
From: Invisible
Date: 20 Feb 2009 09:03:07
Message: <499eb81b@news.povray.org>
>> Then I should make another table to hold all the events that occur in 
>> all the experiments.
>>
>> ExperimentID,EventDateTime,EventID
>> 0,blah,1
>> 0,blah,0
>> 0,blah,2
>> 0,blah,1
>> 1,blah,1
>> ...
>>
>> OK.  That all seems quite basic to me so far and seems the best way to 
>> organise things.
>>
>> Now, is it possible to do a search using SQL that does something like 
>> this: Find all the times that an experiment has gone over temperature 
>> while switched on (ie after a switched on event but not after a 
>> switched off event)?  This is beyond my basic knowledge how I would do 
>> such a thing without writing some code to manually search the results 
>> and checking times.
> 
> Mmm, difficult to see, the Dark Side is...
> 
> I would suggest a 3-way self-join of the event table with itself. Find 
> all occurrances of event #0, event #1 and event #2 in the same 
> experiment, with constraints on the time orderings therein.
> 
> If that makes sense?

SELECT *
FROM EventRecord AS X, EventRecord AS Y, EventRecord AS Z
WHERE
   X.ExperimentID = Y.ExperimentID AND
   Y.ExperimentID = Z.ExperimentID AND
   X.EventID = 0 AND
   Y.EventID = 2 AND
   Z.EventID = 1 AND
   X.EventDateTime < Y.EventDateTime AND
   Y.EventDateTime < Z.EventDateTime;

Or similar. (It's been a while since I did SQL...)


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.