SELECT field1, MAX(field4) OVER (PARTITION BY field3) AS field2
FROM #table1
Though following clarification in the comments...
I think what i really was looking for
was one record per field3, the
max(field4) and the corresponding
field1. And I think the assumption
would have to be made that field1 and
field3 has a strictly one-many
relationship (aka a value of field3
could never have two corresponding
values of field1)
... I think this is what you actually need.
WITH cte As
(
SELECT field1, field3,field4,
ROW_NUMBER() OVER (PARTITION BY field3 ORDER BY field4 DESC) AS RN
FROM #table1
)
SELECT field1, field3,field4
FROM cte
WHERE RN=1