Assuming record value is unique...declare @t table ([Key] int, Record int, Code varchar(10), Amount int)insert @t select 12, 1, 'A', 100union all select 12, 2, 'B', 0union all select 12, 3, 'C', 200union all select 12, 4, 'D', 0union all select 13, 1, 'A', 150union all select 13, 2, 'B', 150union all select 13, 3, 'C', 0select a.* from @t a inner join ( select [Key], max(Record) as Record from @t where Amount > 0 group by [Key]) b on a.[Key] = b.[Key] and a.Record = b.Record
If the record value isn't always unique, it would be useful to know what version of SQL you are using...Ryan Randall Solutions are easy. Understanding the problem, now, that's the hard part.