Your example suggests a maximum of two possible values of field3 for each field1, in which case,
select field1,
min_field3 field3_1,
case when max_field3 !=min_field3 then max_field3
else null
end field3_2
from
(
select field1,
min(field3) min_field3,
max(field3) max_field3
from tab1
group by field1
)
The in-line view is not required, but it makes it a little clearer what is going on
Bookmarks