【问题标题】:KDB appending tables with different columnsKDB 附加具有不同列的表
【发布时间】:2017-06-01 08:58:06
【问题描述】:

我有两个表,它们有一些共同的列和另一个表没有的一些列。

atab:flip `items`sales`prices`athing!(`anut`abolt`acam`acog;6 8 0 3;10 20 15 20; 50.2 32.6 1.18 -3.9)

btab:flip `items`sales`prices`bthing!(`bnut`bbolt`bcam`bcog;6 8 0 3;10 20 15 20; 1 0 0 1)

我正在尝试将它们组合在一起,以便该列将其设置为两个表的并集,因此在我的情况下,列将是项目、销售额、价格、athing、bthing,并且初始表没有相应的列, 填充一些 n/a 值

这里失败了

atab upsert btab

错误

ERROR:mismatch

有没有办法让我(轻松)做到这一点?

【问题讨论】:

    标签: kdb q-lang


    【解决方案1】:
    q)atab uj btab
    items sales prices athing bthing
    --------------------------------
    anut  6     10     50.2
    abolt 8     20     32.6
    acam  0     15     1.18  
    acog  3     20     -3.9
    bnut  6     10            1
    bbolt 8     20            0
    bcam  0     15            0
    bcog  3     20            1
    

    http://code.kx.com/q/ref/joins/#uj-ujf-union-join

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-08-25
      • 1970-01-01
      • 1970-01-01
      • 2020-03-04
      • 2019-12-06
      • 1970-01-01
      相关资源
      最近更新 更多