[GIS] Writing query to select MIN and MAX values by groups

arcgis-10.2arcgis-desktoppersonal-geodatabasesql

In ArcMap 10 i'm working in a Personal Geodatabase where the points (see screenshot below) represent the number of each house in the street. Each point has an ObjectID. This ObjectID is an unique value for each "link" of the street to which all the points are related.enter image description here

I have a total of 35,000 points (house numbers), which are all related to 14,000 different links. What I want is to select both the MAX and MIN value in each side of the street.
Each side of the street also has a unique ID, which appears in my attribute table as CVEFT. On every link, the CVEFT (for both sides) is different.

This is what my Table looks like:
enter image description here

As you can see in the screenshot above, there are several points (NUMEXT) related to the same link (OBJECTID). You can also see that all the points related to a single link may have 2 different street-side codes (CVEFT).

I want to build a SQL query that allows me to select the MIN and MAX values for every Link, for each side of the street.

Does anyone have any idea of how to do this?

Best Answer

It sounds like you want to do a summary statistics with a min and max of NUMEXT and a case field of CVEFT. This will give you a table with every instance of CVEFT and the minimum and maximum NUMEXT.

Join this table to the PAs_Geodatabase using CVEFT then select where NUMEXT = SumTable.NUMEXT_MAX and NUMEXT = SumTable.NUMEXT_MIN to get the maximum and minimum house numbers for that side of the street.

Related Question