將相鄰行的值複製到新表我有一個有兩列的表,例如Name和Salary。我想提取每個人的工資,比如'Hannah'。然後,這些提取的值應該創建一個新表,值應該在“Hannah”列下。
任何幫助將不勝感激。謝謝
Re:將相鄰行的值複製到新表中謝謝。我確實根據我的數據將字符值更改為數字。有用。我非常感謝你的幫助。萬分感謝 :)
Re:將相鄰行的值複製到新表中 @txnelson ,
不,你是對的。我要編輯並進行修正。
Re:將相鄰行的值複製到新表中考慮到我可能會踩到的機會 @uday_guntupalli 腳趾,我要求您從他的腳本中刪除解決方案選中標記,因為它們不正確並且無法正常工作。
請參閱下面的代碼評估
// This code works correctly
dt = Current Data Table(); // Assuming you have a data table open
dt << Select Where(:Name == "Hannah");
dt1 = dt << Subset(Selected Rows(1), Selected Columns(0));
HannahSalary = dt1:Salary << Get Values;
dt2 = New Table();
// This code will not work.
// The new column is declared as "Character". The set values is a numeric value and
// will not enter the data properly. It needs to be specified as "Numeric"
dt2 << New Column("HannahsSalary",Character, Continuous, << Set Values(HannahSalary));
// This code will not work for the same reason as above, and in addition,
// it places the Salary value on the first n rows of the data table, no matter
// where the rows for "Hannah" are.
dt << New Column("HannahsSalary",Character, Continuous, << Set Values(HannahSalary));Re:將相鄰行的值複製到新表中太棒了.. 謝謝
Re:將相鄰行的值複製到新表中如果將其添加到我提供的腳本中,它將向初始數據表中添加一個新列;
dt << New Column("Hannah",formula(If(dt:Name == "Hannah", dt:Salary)));Re:將相鄰行的值複製到新表中 @powerpuff ,
假設您要將數據表添加到isopen:
更正數據類型(在編輯中)
dt = Current Data Table() ;
dt << New Column("HannahsSalary",Numeric,Continuous, << Set Values(HannahSalary));
Re:將相鄰行的值複製到新表中嘿Uday,
另外,您能告訴我如何將此列添加到現有表中嗎?
Re:將相鄰行的值複製到新表中這很有效,非常感謝。
Re:將相鄰行的值複製到新表中 @powerpuff ,
像這樣的東西?這是一個解釋方法的示例 - 如果您需要精確的代碼 - 可以在示例數據上實現相同的方法,也可以提供表的子集
已編輯 - 更正數據類型
dt = Current Data Table(); // Assuming you have a data table open
dt << Select Where(:Name == "Hannah");
dt1 = dt << Subset(Selected Rows(1), Selected Columns(0));
HannahSalary = dt1:Salary << Get Values;
dt2 = New Table();
dt2 << New Column("HannahsSalary",Numeric,Continuous, << Set Values(HannahSalary));
Re:將相鄰行的值複製到新表中我認為這應該有效
Names Default To Here( 1 );
dt = Current Data Table();
dt << select where( :Name == "Hannah" );
dt2 = dt << subset( selected rows( 1 ), columns( "Salary" ) );
dt2:Salary << set name( "Hannah" );