    # File lib/active_record/connection_adapters/oracle_adapter.rb, line 463
            def distinct(columns, order_by)
              return "DISTINCT #{columns}" if order_by.blank?

              # construct a valid DISTINCT clause, ie. one that includes the ORDER BY columns, using
              # FIRST_VALUE such that the inclusion of these columns doesn't invalidate the DISTINCT
              order_columns = order_by.split(',').map { |s| s.strip }.reject(&:blank?)
              order_columns = order_columns.zip((0...order_columns.size).to_a).map do |c, i|
                "FIRST_VALUE(#{c.split.first}) OVER (PARTITION BY #{columns} ORDER BY #{c}) AS alias_#{i}__"
              end
              sql = "DISTINCT #{columns}, "
              sql << order_columns * ", "
            end