日期:2014-05-17  浏览次数:20548 次

重复的列值 ,只显示第一行,其他的显示为空。
这样的一个数据的排列,
col1                col2               col3
1                    1                   2
1                    1                   3
1                    1                   4
2                    2                   5
2                    2                   6
2                    3                   7

显示成这样的
col1                col2               col3
1                    1                   2
                                         3
                                         4
2                    2                   5
                                         6
2                    3                   7
请教这语法?多谢!

------解决方案--------------------

select col1=(case when exists(select 1 from tb t2 where t1.col1=t2.col1 and t1.col2=t2.col2 and t1.col3>t2.col3) then '' else rtrim(col1) end),
col2=(case when exists(select 1 from tb t2 where t1.col1=t2.col1 and t1.col2=t2.col2 and t1.col3>t2.