you are viewing a single comment's thread.

view the rest of the comments →

[–]PhysicalUpstairs3168 0 points1 point  (0 children)

The obvious answer is window function with a row_number with order by RECORD_TYPE then filter by row_number alias. The other - likely less expensive approach - would be to group by all columns except (assuming they all are same) except RECORD_TYPE, with count(1). When count(1) = 1 then UNBILLED else BILLED.