Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-20013

Should be able to use FIRST_VALUE as non-window function, like LAST_VALUE

    XMLWordPrintable

Details

    • Task
    • Status: Open (View Workflow)
    • Minor
    • Resolution: Unresolved
    • None
    • None
    • None

    Description

      It would be nice if FIRST_VALUE() was also usable in non-window form as

      FIRST_VALUE(expr,[expr,...])

      where it would evaluate all arguments in order, and return the first one. This is both for the obvious symmetry with LAST_VALUE(), but also because sometimes it's more natural to write the expression you want to return first, e.g.

      SELECT a, b, c, FIRST_VALUE(d, @var1:=e, @var2:= f) FROM table;

      as opposed to:

      SELECT a, b, c, LAST_VALUE(@var1:=e, @var2:= f, d) FROM table;

      I realize this is basically cosmetic and doesn't actually add any functionality, but it would be nice to have nonetheless, and I imagine it'd be very simple to implement.

      Attachments

        Activity

          People

            Unassigned Unassigned
            Dean T Dean Trower
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.