Uploaded image for project: 'Phoenix'
  1. Phoenix
  2. PHOENIX-1749

ORDER BY should support ordinal position as well as expression

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 4.4.0
    • None
    • None

    Description

      In postgreSQL (and many others DBs) you can specify not only column name for the ORDER BY but column number (position in SELECT part) as well as column alias.

      see:
      http://www.postgresql.org/docs/9.4/static/queries-order.html
      http://www.postgresql.org/docs/9.4/static/sql-select.html#SQL-GROUPBY

      Adding such support would be very helpful and sometimes necessary.

      I can provide real queries example if required but basically we want something like this

      given query
      SELECT a, b, TRUNC(current_date(),'HOUR') AS date_truncated FROM table
      we want
      ORDER BY 1 ASC, 2 DESC
      ORDER BY date_truncated

      Having just column number would cover both but having column alias would make queries more readable and human friendly. Plus make it one little stem closer to postgreSQL and SQL standard.

      Attachments

        1. PHOENIX-1749.patch
          6 kB
          Alicia Ying Shu
        2. PHOENIX-1749-v1.patch
          6 kB
          Alicia Ying Shu
        3. Phoenix-1749-v2.patch
          23 kB
          Alicia Ying Shu
        4. PHOENIX-1749-v3.patch
          23 kB
          James R. Taylor

        Issue Links

          Activity

            People

              aliciashu Alicia Ying Shu
              sergey.b Serhiy Bilousov
              Votes:
              0 Vote for this issue
              Watchers:
              9 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: