selecting maximum value of an attribute table to create a layer

519
6
10-08-2021 11:34 AM
SalvoA
by
New Contributor II

Hi,

I would create an event layer  in ArcMap selecting values from a table  with a sql query.

In particular I would like to select the row with the maximum value of an attribute, so
I thinked a sql query as:
RealPosition.Easting = ( SELECT MAX ( RealPosition.Easting ) FROM RealPosition )
where RealPosition is the table and Easting is the attributo but the select tool but it says an invalid sql expression was used.
How can I solve?
Thanks.
0 Kudos
6 Replies
JayantaPoddar
MVP Esteemed Contributor

In ArcMap, I can open the table > Table Options > Select By Attributes.

Use a similar expression

FIELD_NAME = (SELECT MAX(FIELD_NAME) FROM TABLE_NAME)

 

JayantaPoddar_0-1633719589362.png

 

Try 

Easting = (SELECT MAX(Easting) FROM RealPosition)

 



Think Location
0 Kudos
SalvoA
by
New Contributor II

Thanks for your replay.It's work for a simple table, but I have a table joined with another.Could this be the problem?

0 Kudos
JayantaPoddar
MVP Esteemed Contributor

Oh!

A similar expression (to your original expression) works for me. My tables are stored in a File Geodatabase.

JayantaPoddar_0-1633727941958.png

 



Think Location
0 Kudos
SalvoA
by
New Contributor II

Thanks.

The problem is that I used a "join" where a "relate" was needed, so it didn't work.

I have another problem:

I want select max value between rows that have an attribute equal to a value(for example Unit = 'TAB1')Is it possible to do "sequential sql queries "?

Thanks.

0 Kudos
JoshuaBixby
MVP Esteemed Contributor

I think I understand the question, but an example using some sample data would be most helpful.  If you want to select the maximum value in a group:

IDValue
A5
A2
A10
B3
C4
C6

It can be possible, but it depends on the back-end data source because SQL support is based on the data source.

0 Kudos
SalvoA
by
New Contributor II

Yes, your example is correct.

what kind of database should I use?

Thanks.

0 Kudos