A join will work out for you.
<pre>INSERT INTO AnotherTable
SELECT a.GridCode, a.State, a.Area
FROM Table
JOIN (SELECT GridCode, max(Area) as Area
FROM Table
GROUP BY GridCode) b ON a.GridCode = b.GridCode AND a.Area = b.Area</pre>
If each GridCode contains only one state (I assumed that this was not the case).
<pre>INSERT INTO AnotherTable
SELECT GridCode, State, max(Area)
FROM Table
GROUP BY GridCode, State</pre>
The first example I gave is the more precise example.
Discuss This Question: 1  Reply