Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2006

    Unanswered: Select Max value from prior where conditions

    I can't figure this out for the life of me. Wanted to know if it's possible to select certain date conditions in a query, then later reference those conditions and to only select the max of them.

    I need to do this dynamically as I do not know what the max value is. I've provided an example below:

    Select var1
    From table1
    (Date1 = '11/30/2005')
    (Date1 = '12/31/2005')
    and Date1 = (Max of previously selected values e.g. '12/31/2005')

    What I can't figure out is how to dynamically retrieve the max of 11/31/2005 and 12/31/2005. Any ideas are greatly appreciated.

  2. #2
    Join Date
    Jun 2003
    Provided Answers: 1
    Not exactly sure what your business logic is, but you might try loading your date values into a temporary table or table variable, and then referencing it as much as you want in your query.
    If it's not practically useful, then it's practically useless.

    blindman "sqlblindman"

Posting Permissions

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