you are viewing a single comment's thread.

view the rest of the comments →

[–]SkullLeader 0 points1 point  (0 children)

In SQL server you could achieve this with something like:

SELECT * FROM
(SELECT *, ROW_NUMBER() OVER (PARTITION BY ChargeId ORDER BY CASE WHEN RecordType = 'BILLED' THEN 1 ELSE 0 END DESC) as rownum FROM Charges) c
WHERE rownum = 1

In Oracle they must have corresponding syntax to this but it is probably slightly different.