List:General Discussion« Previous MessageNext Message »
From:Fred Lindberg Date:March 30 1999 8:43pm
Subject:Re: Complicated Query
View as plain text  
On Tue, 30 Mar 1999 12:33:05 -0800, Mike Machado wrote:

>Now I want to know everyone who was logged in between '1999-03-29
>02:00:00' and '1999-03-29 04:00:00'

If "between" means "at any time in the interval", the set you want is
the union of:

logged in before [low] and did not log out before [low] (already on
when the interval started)
logged in after [low] and before [hi] (during the interval)

So if your range is Tin...Tout

... WHERE Tin < [low] AND Tout > [low] OR Tin > [low] AND Tin < [hi]

If "between" means "during the entire interval" you're looking for Tin
< [low] and Tout > [hi]. Also, depending on what you mean with between,
the equal condition may need to be included (i.e. > maybe should be >=,
etc).


-Sincerely, Fred

(Frederik Lindberg, Infectious Diseases, WashU, St. Louis, MO, USA)


Thread
Complicated QueryMike Machado30 Mar
  • Re: Complicated QueryChristian Mack31 Mar
  • Re: Complicated QueryWayne Cease31 Mar
Re: Complicated QueryFred Lindberg30 Mar
Re: Complicated Query("Christian Mack")31 Mar