关于数据库表结构的操作
ProductSN Gain_min Gain_max VSWR_ANT_879 VSWR_Rx F_ANT_Rx_20 F_ANT_Rx_816
A8319050032411501784NULLNULLNULL NULL NULLNULL
A8319050032411501784NULLNULLNULL NULL NULL52.1600
A8319050032411501784NULLNULLNULL NULL 106.8700NULL
A8319050032411501784NULLNULLNULL 25.3600 NULLNULL
A8319050032411501784NULLNULL23.3800 NULL NULLNULL
A831905003241150178419.520020.4100NULL NULL NULLNULL
上面是我的表结构 想把它变成一行(像下面的一样) 有什么办法没
ProductSN Gain_min Gain_max VSWR_ANT_879 VSWR_Rx F_ANT_Rx_20 F_ANT_Rx_816
A8319050032411501784 19.5200 20.4100 23.3800 25.3600 106.8700 52.1600
[解决办法]
- SQL code
select ProductSN,max(col1) col1,max(col2) col2,max(col3) col3,...from tbgroup by ProductSN
[解决办法]
- SQL code
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))goinsert into tb select 'A8319050032411501784',NULL, NULL ,NULL, NULL, NULL, NULL union allselect 'A8319050032411501784',NULL,NULL, NULL, NULL ,NULL ,52.1600 union allselect 'A8319050032411501784',NULL, NULL, NULL ,NULL, 106.8700, NULL union allselect 'A8319050032411501784',NULL, NULL, NULL, 25.3600 ,NULL, NULL union allselect 'A8319050032411501784',NULL ,NULL ,23.3800, NULL, NULL, NULL union allselect 'A8319050032411501784',19.5200, 20.4100, NULL, NULL ,NULL, NULLgoselect 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_816from tbgroup by ProductSN/*ProductSN Gain_min Gain_max VSWR_ANT_879 VSWR_Rx F_ANT_Rx_20 F_ANT_Rx_816A8319050032411501784 19.520000 20.410000 23.380000 25.360000 106.870000 52.160000*/