How to convert tic data to 5minutes OHLC ?

there,I am learning KDB+ . and have load the tic data into the table W asbelow. My question is, how to tansfer the data into 5 (or n) minutesOHLCVA ?“Stk_ID”,“Date”,“Time”,“Price”,“Chg”,“Vol”,“Amt”,"Ty"300032,2011-03-03,09:51:40,20.40,0.00,10.0,20400.0,S300032,2011-03-03,09:51:30,20.40,-0.01,9.0,18360.0,S300032,2011-03-03,09:51:00,20.41,0.01,2.0,4082.0,B300032,2011-03-03,09:51:00,20.40,-0.01,115.0,234599.0,S300032,2011-03-03,09:50:45,20.41,0.00,10.0,20410.0,S300032,2011-03-03,09:50:45,20.41,-0.02,7.0,14287.0,S300032,2011-03-03,09:50:20,20.43,-0.01,4.0,8172.0,S300032,2011-03-03,09:50:05,20.44,0.01,25.0,51100.0,B300032,2011-03-03,09:50:00,20.43,-0.01,28.0,57204.0,SI use such Q code to get 1 minute data, but don’t know how to get 5minutes . :select Open: first price,High: max price, Low: min price,Close: lastprice,Vol: sum vol, Amt: sum amt,Avg_Price: ((sum amt)%(sum vol))%100by stk_id,time.hh,time.mm from asc Wresult:stk_id hh mm| Open High Low Close Vol Amt Avg_Price------------| ----------------------------------------------------000001 9 30| 16.24 16.24 16.22 16.24 3253 5282086 16.23758000001 9 31| 16.22 16.24 16.21 16.21 1974 3204276 16.2324000001 9 32| 16.23 16.23 16.2 16.2 3764 6102207 16.21203000001 9 33| 16.21 16.21 16.19 16.2 4407 7143120 16.20858000001 9 34| 16.2 16.2 16.19 16.19 1701 2756614 16.20584000001 9 35| 16.19 16.21 16.19 16.21 2756 4466988 16.20823000001 9 36| 16.22 16.25 16.22 16.24 3123 5076089 16.25389000001 9 37| 16.25 16.27 16.25 16.27 1782 2897340 16.25892Thanks, Halley

charset=us-ascii
X-Mailer: iPhone Mail (9A405)
In-Reply-To: <2287c6a5-7641-4e21-94ea-620edc18f6b5@f35g2000yqm.googlegroups.com>
Message-Id:
Date: Thu, 1 Dec 2011 07:26:08 -0500
To: “personal-kdbplus@googlegroups.com

Mime-Version: 1.0 (1.0)

http://code.kx.com/wiki/Reference/xbar

You can use xbar function for this

select Open: first price,High: max price, Low: min price,Close: last
price,Vol: sum vol, Amt: sum amt,Avg_Price: ((sum amt)%(sum vol))%100
by stk_id, time.hh, 5 xbar time.mm from `time xasc w

It work, Thanks,