大家好
我有兩個表,我想只分配Main_Table的特定列,它們在Cols_Needed表中作為行值出現。
例如,對於下表,我想要將Main_Table的A,I和F列為子集,因為“A”,“I”和“F”在Cols_Needed表中作為行值存在。
謝謝!
艾哈邁德
dt =新表(“Main_Table”,
添加行(8),
新列(“A”,數字,連續,格式(“最佳”,12),設置值([1,2,3,1,1,1,1,1])),
新列(“B”,數字,連續,格式(“最佳”,12),設置值([4,5,6,1,1,1,1,1])),
新列(“C”,數字,連續,格式(“最佳”,12),設置值([7,8,9,1,1,1,1,1])),
新列(“D”,數字,連續,格式(“最佳”,12),設置值([10,11,12,1,1,1,1,1])),
新列(“E”,數字,連續,格式(“最佳”,12),設置值([13,14,15,1,1,1,1,1])),
新列(“F”,數字,連續,格式(“最佳”,12),設置值([5,2,3,1,1,1,1,1])),
新列(“G”,數字,連續,格式(“最佳”,12),設置值([99,8,9,1,1,1,1,1])),
新列(“I”,數字,連續,格式(“最佳”,12),設置值([15,14,15,1,1,1,1,1]))
);
dt =新表(“Cols_Needed”,
添加行(3),
新列(“Col”,字符,設置值({“A”,“I”,“F”})),
新列(“Val”,數字,連續,格式(“最佳”,12),設置值([1,2,3]))
);
Names Default To Here( 1 );
dt1 = New Table( "Main_Table",
Add Rows( 8 ),
New Column( "A", Numeric, Continuous, Format( "Best", 12 ), Set Values( [1, 2, 3, 1, 1, 1, 1, 1] ) ),
New Column( "B", Numeric, Continuous, Format( "Best", 12 ), Set Values( [4, 5, 6, 1, 1, 1, 1, 1] ) ),
New Column( "C", Numeric, Continuous, Format( "Best", 12 ), Set Values( [7, 8, 9, 1, 1, 1, 1, 1] ) ),
New Column( "D", Numeric, Continuous, Format( "Best", 12 ), Set Values( [10, 11, 12, 1, 1, 1, 1, 1] ) ),
New Column( "E", Numeric, Continuous, Format( "Best", 12 ), Set Values( [13, 14, 15, 1, 1, 1, 1, 1] ) ),
New Column( "F", Numeric, Continuous, Format( "Best", 12 ), Set Values( [5, 2, 3, 1, 1, 1, 1, 1] ) ),
New Column( "G", Numeric, Continuous, Format( "Best", 12 ), Set Values( [99, 8, 9, 1, 1, 1, 1, 1] ) ),
New Column( "I", Numeric, Continuous, Format( "Best", 12 ), Set Values( [15, 14, 15, 1, 1, 1, 1, 1] ) )
);
dt2 = New Table( "Cols_Needed",
Add Rows( 3 ),
New Column( "Col", Character, Set Values( {"A", "I", "F"} ) ),
New Column( "Val", Numeric, Continuous, Format( "Best", 12 ), Set Values( [1, 2, 3] ) )
);
subsetCols = Column( dt2, "Col" ) << getValues;
dt3 = dt1 << Subset( Columns( subsetCols ) );