3
我對此感到困惑:請看下面的內容。爲什麼線條(1)和(2)產生不同的結果?謝謝你的幫助。kdb函數不起作用
q)trade
date open high low close volume sym
------------------------------------------------
2006.10.03 24.5 24.51 23.79 24.13 19087300 AMD
2006.10.03 27.37 27.48 27.21 27.37 39386200 MSFT
2006.10.03 24.1 25.1 23.95 25.03 17869600 AMD
2006.10.03 27.39 27.96 27.37 27.94 82191200 MSFT
2006.10.03 24.8 25.24 24.6 25.11 17304500 AMD
2006.10.03 27.92 28.11 27.78 27.92 81967200 MSFT
2006.10.03 24.66 24.8 23.96 24.01 17299800 AMD
2006.10.03 27.76 28 27.65 27.87 36452200 MSFT
q)extr
{[t;c;r] select from t where (`$1#'string c) within r}
q)
q)
q)extr[trade;sym;`K`Z] /(1)
date open high low close volume sym
------------------------------------------------
2006.10.03 27.37 27.48 27.21 27.37 39386200 MSFT
q)
q)
q)select from trade where (`$1#'string sym) within `K`Z /(2)
date open high low close volume sym
------------------------------------------------
2006.10.03 27.37 27.48 27.21 27.37 39386200 MSFT
2006.10.03 27.39 27.96 27.37 27.94 82191200 MSFT
2006.10.03 27.92 28.11 27.78 27.92 81967200 MSFT
2006.10.03 27.76 28 27.65 27.87 36452200 MSFT