【问题标题】:KDB get only the rows present only in one tableKDB 仅获取仅存在于一张表中的行
【发布时间】:2021-06-15 12:00:23
【问题描述】:

我有两个表 table1 和 table2。两者都有 4 列具有相同的列名。 table1 有 50 行,table2 有 100 行。如何仅从 table2 中获取那些在 table1 中不存在的行。我尝试执行左连接,但我不能这样做,因为我们不能使用所有列进行左连接。

【问题讨论】:

    标签: kdb


    【解决方案1】:

    由于表是字典列表,您可以使用except keyword 排除table2 中的所有行,这些行位于table1 中。

    例如:

    q)table1:([]a:til 3;b:3#.Q.a;c:3#.Q.A)
    q)table1
    a b c
    -----
    0 a A
    1 b B
    2 c C
    
    q)table2:([]a:til 6;b:6#.Q.a;c:6#.Q.A)
    q)table2
    a b c
    -----
    0 a A
    1 b B
    2 c C
    3 d D
    4 e E
    5 f F
    
    q)table2 except table1
    a b c
    -----
    3 d D
    4 e E
    5 f F
    

    【讨论】:

      猜你喜欢
      • 2016-07-08
      • 1970-01-01
      • 2011-09-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多