Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2012
    Posts
    4

    Unanswered: using max with where condition

    i have a table like this

    ID DATE time status

    01 11/11/2011 10.23 Entry
    02 11/11/2011 11 .47 Exit
    03 11/11/2011 12.54 Entry
    04 11/11/2011 2.54 Exit

    i want to select the minmum time from entry and maximum time in exit

    the status should be checked when taking the max and min values

    how to do this

  2. #2
    Join Date
    Apr 2012
    Posts
    213
    Try something like that:

    Code:
    select
        MIN(case when status = 'Entry' then TimeColumn end) as MinEntry,
        MAX(case when status = 'Exit' then TimeColumn end) as MaxExit
    from MyTable
    Hope this helps.

Posting Permissions

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