假设我有一张这样的桌子:
col1 col2 col3
row1 1 null null
row2 null 2 null
row3 null null 3
所有数据类型都是数字,整数或长整数。我需要这样一张桌子:
col1 col2 col3
row1 1 2 3
如何使用sql语句完成此操作?我假设我必须创建一个新表并插入一个带有select语句的新行,但我更多的是编码器,不知道我应该使用什么样的语句。谢谢你的帮助。
答案 0 :(得分:3)
Select MAX(Merge_Table_Parcel_1.txtFrequency1) AS Frequency1,
MAX(Merge_Table_Parcel_1.SUM_INST_N) AS SUM_INST_N1,
MAX(Merge_Table_Parcel_1.SUM_INST_D) AS SUM_INST_D1,
MAX(Merge_Table_Parcel_1.SUM_CTRN_D) AS SUM_CTRN_D1,
MAX(Merge_Table_Parcel_1.SUM_CTRN_N) AS SUM_CTRN_N1,
MAX(Merge_Table_Parcel_1.SUM_TRAN_N) AS SUM_TRAN_N1,
MAX(Merge_Table_Parcel_1.SUM_PPU) AS SUM_PPU1,
MAX(Merge_Table_Parcel_1.SUM_PPUJOBS) AS SUM_PPUJOBS1,
MAX(Merge_Table_Parcel_1.SUM_DAYT) AS SUM_DAYT1,
MAX(Merge_Table_Parcel_1.SUM_RESD_D) AS SUM_RESD_D1,
MAX(Merge_Table_Parcel_1.SUM_RESD_N) AS SUM_RESD_N1,
MAX(Merge_Table_Parcel_1.SUM_ON_STRN_D) AS SUM_ON_STRN_D1,
MAX(Merge_Table_Parcel_1.SUM_ON_STRN_N) AS SUM_ON_STRN_N1
FROM Merge_Table_Parcel_1
简单,我知道,但我立即看到它。感谢所有做出回应的人,以及让我指向正确方向的sllev。
答案 1 :(得分:0)
选择 MAX (col1)为Col1,
MAX (col2)为Col2,
MAX (col3)为Col3
FROM table_Name
我认为这会有所帮助....