making some assumptions on how you want certain values. If this is not right, please provide more data, or more explanation.create table #yak (lfdlbnr bigint, Y1 int, Y2 int, y3 int, y4 int, Yak varchar(5), y5 int)insert into #yak values (26088131, 2, 2, 10530, 194, 'KON', 1) ,(26088131, 1, 2, 10530, 1, 'KON', 1)select * from #yakselect lfdlbnr, MAX(y1), MAX(y2), MAX(y3), MIN(y4), MAX(y4), Yak, MAX(y5)from #yakgroup by lfdlbnr, Yak drop table #yak
How to ask: http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx