database - How to select first record prior/after a given timestamp in KDB? -
i pulling in records 1min leading timestamp (e.g. if timestamp i'm interested in 2014.04.14t09:30
):
select prices timestamp within 2014.04.14t09:29 2014.04.14t09:30, stock=`goog
however, not robust. previous record may @ 09:25am
, query returns nothing. query may return hundreds of records if there have been lot of price changes, though need last record returned.
i know can done asof join, want avoid time being prices
big @ present.
i interested in doing same, in finding first record after given timestamp.
note prices
splayed table
select last record before given timestamp:
q)select price timestamp<2014.04.14t09:30,stock=`goog,i=last
select first record after given timestamp:
q)select price timestamp>2014.04.14t09:30,stock=`goog,i=first
Comments
Post a Comment