Select to view content in your preferred language

One-to-first join — Control what related record gets used

4763
23
12-03-2022 10:43 AM
Status: Open
Labels (1)
Bud
by
Esteemed Contributor

It would be helpful if we could control the logic used for getting the records on the many side of [one-to-first] joins.

For example, choose an ORDER BY field: Grab the related record with the latest date, or the largest integer, etc. Specify ascending or descending order.

Even better, make it a user-defined ORDER BY sql clause, so that we can use specialized logic like:


Related: Choose if join will be 1:1 or 1:Many

23 Comments
Bud
by

Possible workarounds:

Since one-to-first joins use the related record that has the lowest OBJECTID, we could consider sorting the rows for each grouping/common ID, along with generating a new OBJECTID on the sorted data, using techniques like:

  1. Query layer (enterprise geodatabases only) (untested)
    select
        cast(rownum as int) as objectid, --Fake OBJECTID. Uses sorted subquery.
        a1,
        b1
    from
        (select
            a1,
            b1
        from
            table_1
        order by
            a1,
            b1 desc)
  2. Database view (mobile or enterprise geodatabase; file geodatabase SQL is likely too limited) (untested)
  3. Sort geoprocessing tool (static output)
  4. Other? Python?

 

ROW_NUMBER function in FGDB SQL
https://community.esri.com/t5/arcgis-pro-ideas/row-number-function-in-fgdb-sql/idc-p/1526715/highlig... 

Bud
by

Related: