Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1
  1. #1
    Regular Coder
    Join Date
    Apr 2012
    Location
    St. Louis, MO
    Posts
    985
    Thanks
    7
    Thanked 101 Times in 101 Posts

    ORACLE: Can COALESCE() be nested inside MAX()?

    Hello, everyone.

    In Oracle (10g and 11g), can COALESCE() be nested inside MAX()?

    For example, I want to get the current MAX value of a column used for sort order of records (ie, 1,2,3,4..) for a particular application listing; going to add one to it and use it for the next entry for that app. So I was using
    Code:
    SELECT MAX(sort_order)+1 FROM table WHERE app_id = 'F8'
    But then it occurred to me that when an application is being entered for the first time, there won't be a sort order (separate table for applications.) So, I'm wondering if I could do:
    Code:
    SELECT MAX(COALESCE(sort_order,0))+1 FROM table WHERE app_id = 'F8'
    UPDATE: Apparently, yes, it can.

    Respectfully,
    Last edited by WolfShade; 08-03-2012 at 06:18 PM.
    ^_^

    If anyone knows of a website that can offer ColdFusion help that isn't controlled by neurotic, pedantic jerks* (stackoverflow.com), please PM me with a link.
    *
    The neurotic, pedantic jerks are not the owners; just the people who are in control of the "popularity contest".


 

Tags for this Thread

Posting Permissions

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