Search code examples
kdb

How to fill nulls in a KDB table column?


q)t:flip `name`iq!(`Dent``Prefect;98 32 34)

q)t
name    iq
----------
Dent    98
        32
Prefect 34

How can I form an a conditional query to act on the column name

q)select case when name is null then `Empty else name ,iq from t

Expected output:

name    iq
----------
name    iq
Dent    98
Empty   32
Prefect 34

Solution

  • Also https://code.kx.com/q/ref/lists/#vector-conditional can be used as a method of basing a column on an expression:

    q)select ?[null name;`Empty;name],iq from t
    name    iq
    ----------
    Dent    98
    Empty   32
    Prefect 34