|
|
|
|
|
by gwu78
3318 days ago
|
|
"The task is to sum the values for each key and print the key with the largest sum." What is the smart way to do this in kdb+? This is my naive, sloppy 15min approach. Warning: Noob. May offend experienced k programmers. k)`t insert+:`k`v!("CI";"\t")0:`:tsvfile
k)f:{select (*:k),(sum v) from t where k=x}
k)a:f["A"]
k)b:f["B"]
k)c:f["C"]
k)select k from a,b,c where v=(max v)
|
|
EDIT: