Results 1 to 5 of 5
  1. #1
    Lynny is offline Novice
    Windows 10 Access 2016
    Join Date
    Jun 2022
    Posts
    1

    Greatest between two values

    I am connecting to an Access Database table in Python. There is something wrong with the IIF statement in my query when the condition is false it should find the greatest value between col7 and col8. If someone could point me in the right direction. Thanks!



    Code:
    qry2=("select col1, col2, col3, col4, iif(col5 < 1 OR col6 IS NOT NULL, col7, MAX(col7, col8)) as testcoldata  from mytable")

  2. #2
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,858
    Yes, not the correct syntax at all.
    You could use another iif() to determine which is the max value.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  3. #3
    orange's Avatar
    orange is offline Moderator
    Windows 10 Office 365
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,716
    Python has Max function as Lynny show in code. I'm not sure if Python has IIF?

    I am assuming the code presented is Python not vba.

  4. #4
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,858
    I read it as sql?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  5. #5
    orange's Avatar
    orange is offline Moderator
    Windows 10 Office 365
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,716

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Sorting Bar Chart from Greatest to Least
    By scienceguy in forum Reports
    Replies: 3
    Last Post: 07-08-2020, 03:33 PM
  2. Replies: 3
    Last Post: 01-16-2013, 11:56 PM
  3. Only see Greatest Date in query
    By burrina in forum Access
    Replies: 1
    Last Post: 10-25-2012, 02:01 PM
  4. looking for greatest between 5 columns?
    By syphlix in forum Queries
    Replies: 5
    Last Post: 05-03-2011, 10:34 AM
  5. Replies: 1
    Last Post: 03-05-2010, 12:27 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums