日期:2014-05-18 浏览次数:20583 次
select ProductSN,max(col1) col1,max(col2) col2,max(col3) col3,... from tb group by ProductSN
------解决方案--------------------
create table tb(ProductSN varchar(120),Gain_min decimal(18,6), Gain_max decimal(18,6),VSWR_ANT_879 decimal(18,6),VSWR_Rx decimal(18,6),F_ANT_Rx_20 decimal(18,6), F_ANT_Rx_816 decimal(18,6)) go insert into tb select 'A8319050032411501784',NULL, NULL ,NULL, NULL, NULL, NULL union all select 'A8319050032411501784',NULL,NULL, NULL, NULL ,NULL ,52.1600 union all select 'A8319050032411501784',NULL, NULL, NULL ,NULL, 106.8700, NULL union all select 'A8319050032411501784',NULL, NULL, NULL, 25.3600 ,NULL, NULL union all select 'A8319050032411501784',NULL ,NULL ,23.3800, NULL, NULL, NULL union all select 'A8319050032411501784',19.5200, 20.4100, NULL, NULL ,NULL, NULL go select ProductSN,max(Gain_min) Gain_min,max(Gain_max) Gain_max,max(VSWR_ANT_879) VSWR_ANT_879,max(VSWR_Rx) VSWR_Rx,max(F_ANT_Rx_20) F_ANT_Rx_20,max(F_ANT_Rx_816) F_ANT_Rx_816 from tb group by ProductSN /* ProductSN Gain_min Gain_max VSWR_ANT_879 VSWR_Rx F_ANT_Rx_20 F_ANT_Rx_816 A8319050032411501784 19.520000 20.410000 23.380000 25.360000 106.870000 52.160000 */