Results 1 to 3 of 3

Thread: Case When

  1. #1
    Join Date
    Apr 2003
    Posts
    15

    Unanswered: Case When

    I need to use a statement like the following in Access:

    SELECT (case when Max(f1) is null then 0 else Max(f1) end) as 'MDB1Identity' from TR_TripReportHeader

    I keep getting and "Missing Operator" message how can I write this so it works?

    Thanks,

  2. #2
    Join Date
    Sep 2003
    Location
    MI
    Posts
    3,713

    Re: Case When

    Originally posted by BEISKEN
    I need to use a statement like the following in Access:

    SELECT (case when Max(f1) is null then 0 else Max(f1) end) as 'MDB1Identity' from TR_TripReportHeader

    I keep getting and "Missing Operator" message how can I write this so it works?

    Thanks,
    IIf (isnull(MAX([f1])),0,MAX([f1]))

  3. #3
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    Alternatively you can use the nz() function if you are only evaluating for null. You probably should be using IsNull() in your example query as well:

    nz(Max(f1), 0)

Posting Permissions

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