Jean-Paul
Jean-Paul

Reputation: 21150

kdb: delete first record only of where clause

I want to delete only the first record (so might be more) that matches my where clause.

E.g.:

delete from `log where colOne=a, colTwo=b;

To illustrate what I mean (I know it's wrong but you will understand immediately what I mean):

delete[1] from `log where colOne=a, colTwo=b;

How do I do this?

Upvotes: 2

Views: 160

Answers (1)

Ryan Hamilton
Ryan Hamilton

Reputation: 2605

q)t:([] a:10?3)
q)t
a
-
1
2
2
1
0
1
2
0
1
1

q)delete from `t where a=0,i=first i
`t
q)count t
9
q)t
a
-
1
2
2
1
1
2
0
1
1

Upvotes: 4

Related Questions