I have a feature layer "assets" (points) that contains a field "categories_id" which is populated by IDs that refer to the "id" field of the "categories" table (no spatial data). There is another field in this second table which contains a "name" string field. The "assets.categories_id" field is related to the "categories.id".
I would like to count how many different categories (categories_id) exist in the "asset" table and get the name from the "categories" tables.
asset table:
| id | site_id | categories_id | info |
| 1 | 1 | 1 | text1 |
| 2 | 1 | 1 | text2 |
| 3 | 1 | 2 | text3 |
categories table:
| id | name |
| 1 | category 1 |
| 2 | category 2 |
| 3 | category 3 |
| 4 | category 4 |
I realize I can use the "group_by_fields_for_statistics" and "out_statistics" parameters from the FeatureLayer.query function to get the count of every assets.categories_id, but I also need to get the name. What is the best way to accomplish this? Get the stats then do a join?
As a side question: I also wish to do a similar operation with two feature layers (sites and assets). Is there a way to join features based on field value (a basic SQL JOIN) rather than the spatial_relationship (as described here) ? Anyway to do that?
Thank you!