单个记录中的数据

Sri*_*vas 4 sql sql-server select

下面是sql select查询输出.

Col1            Col2    Col3    Col4        Col5    Col6    Col7    Col8    Col9
-------------------------------------------------------------------------------------
General-Surgery John    193850  21/06/2013  Smith   NULL    704.08  NULL    NULL
General-Surgery John    193850  21/06/2013  Smith   2510    NULL    NULL    NULL
General-Surgery John    193850  21/06/2013  Smith   NULL    NULL    NULL    19950
General-Surgery John    193850  21/06/2013  Smith   NULL    NULL    0       NULL
Run Code Online (Sandbox Code Playgroud)

这里Col1,Col2,Col3,Col4,Col5重复..我只想在单个记录中的所有数据(删除NULL)就像下面..

Col1            Col2    Col3    Col4        Col5    Col6      Col7     Col8    Col9
---------------------------------------------------------------------------------------
General-Surgery John    193850  21/06/2013  Smith   704.08    2510     19950   0
Run Code Online (Sandbox Code Playgroud)

在这方面请帮助我

谢谢你的期待.

Luv*_*Luv 10

select 
Col1, 
Col2, 
Col3, 
Col4, 
Col5,
max(isnull(Col6,0)),
max(isnull(Col7,0)),
max(isnull(Col8,0)),
max(isnull(Col9,0))
from table1
group by Col1, Col2, Col3, Col4, Col5
Run Code Online (Sandbox Code Playgroud)

SQL小提琴