Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2004
    Posts
    128

    Unanswered: minimum and maximum in a time range (was "SQL query")

    Hi all,
    If I have the table:

    Date/Time X
    2/12/2004 07:23:00 100
    2/12/2004 07:30:00 200
    2/12/2004 09:30:00 500
    2/12/2004 14:45:00 600
    2/12/2004 15:02:00 100

    I want to get X where it's time interval between the minimum time and the maximum time in the period 06:00:00 to 15:15:00
    My target to get the minimum X and the maximum X between 06:00:00 and 15:15:00 and substarct them.

    Please help
    Thanks

  2. #2
    Join Date
    Sep 2002
    Location
    UK
    Posts
    5,171
    Provided Answers: 1
    select max(x)-min(x)
    from some_table
    where datetime between timestamp '2004-12-02 06:00:00' and timestamp '2004-12-02 15:15:00';

    Of course, specification of dates and times varies from DBMS to DBMS, so the syntax may vary there.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •