سؤال

I have a table that's got some values, and I would like to append another table to this one. The columns in the second table don't entirely match the first.

Please note I am using Q/KDB+ language to achieve this:

For example:

Table 1

Date TypeA TypeB TypeC Aggregate

dt1 A B C ABC

Table 2

Header1 Header2

TypeA X

TypeB Y

TypeC Z

I would like my output to be

Table3

Date TypeA TypeB TypeC Aggregate

dt1 A B C ABC

(null) X Y Z (null)

هل كانت مفيدة؟

المحلول

t:([]date:enlist 2014.01.01;TypeA:enlist `A;TypeB:enlist `B;TypeC:enlist `C;Agg:enlist `ABC)

t2:([]header1:`TypeA`TypeB`TypeC;Header2:`X`Y`Z)

t uj enlist (!) . value flip t2

date       TypeA TypeB TypeC Agg
--------------------------------
2014.01.01 A     B     C     ABC
           X     Y     Z
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top