Hi Gully
<o:p> </o:p>
I think the following line will do what you?re after, as Karan originally suggested:
0!select Total:sum oqm by DateTime,BidOrAsk from update oqm:Orders*Quantity from tab<o:p></o:p>
<o:p> </o:p>
If you also want Price and Ltp in your output, you can add first price, first Ltp to your select statement like so:<o:p></o:p>
<o:p> </o:p>
0!select first Price,first Ltp,Total:sum oqm by DateTime,BidOrAsk from update oqm:Orders*Quantity from tab<o:p></o:p>
<o:p> </o:p>
Here?s sample input and output which seem to match your requirements:<o:p></o:p>
<o:p> </o:p>
q)tab:(DateTime:(10#.z.z-1%24),10#.z.z;Price:273.15,273.1,273.05,273,272.95,273.2,273.3,273.35,273.4,273.45,273.15,273.1,273.05,273,272.95,273.2,273.3,273.35,273.4,273.45;BidOrAsk:raze 5#‘(0;1;0;1);Quantity:20#10;Orders:raze 5#’(1;2;4;5);Ltp:20#273.05)<o:p></o:p>
q)tab<o:p></o:p>
DateTime Price BidOrAsk Quantity Orders Ltp<o:p></o:p>
--------------------------------------------------------------<o:p></o:p>
2018.03.21T15:00:39.118 273.15 0 10 1 273.05<o:p></o:p>
2018.03.21T15:00:39.118 273.1 0 10 1 273.05<o:p></o:p>
2018.03.21T15:00:39.118 273.05 0 10 1 273.05<o:p></o:p>
2018.03.21T15:00:39.118 273 0 10 1 273.05<o:p></o:p>
2018.03.21T15:00:39.118 272.95 0 10 1 273.05<o:p></o:p>
2018.03.21T15:00:39.118 273.2 1 10 2 273.05<o:p></o:p>
2018.03.21T15:00:39.118 273.3 1 10 2 273.05<o:p></o:p>
2018.03.21T15:00:39.118 273.35 1 10 2 273.05<o:p></o:p>
2018.03.21T15:00:39.118 273.4 1 10 2 273.05<o:p></o:p>
2018.03.21T15:00:39.118 273.45 1 10 2 273.05<o:p></o:p>
2018.03.21T16:00:39.118 273.15 0 10 4 273.05<o:p></o:p>
2018.03.21T16:00:39.118 273.1 0 10 4 273.05<o:p></o:p>
2018.03.21T16:00:39.118 273.05 0 10 4 273.05<o:p></o:p>
2018.03.21T16:00:39.118 273 0 10 4 273.05<o:p></o:p>
2018.03.21T16:00:39.118 272.95 0 10 4 273.05<o:p></o:p>
2018.03.21T16:00:39.118 273.2 1 10 5 273.05<o:p></o:p>
2018.03.21T16:00:39.118 273.3 1 10 5 273.05<o:p></o:p>
2018.03.21T16:00:39.118 273.35 1 10 5 273.05<o:p></o:p>
2018.03.21T16:00:39.118 273.4 1 10 5 273.05<o:p></o:p>
2018.03.21T16:00:39.118 273.45 1 10 5 273.05<o:p></o:p>
<o:p> </o:p>
q)0!select first Price,first Ltp,Total:sum oqm by DateTime,BidOrAsk from update oqm:Orders*Quantity from tab<o:p></o:p>
DateTime BidOrAsk Price Ltp Total<o:p></o:p>
-------------------------------------------------------<o:p></o:p>
2018.03.21T15:00:39.118 0 273.15 273.05 50<o:p></o:p>
2018.03.21T15:00:39.118 1 273.2 273.05 100<o:p></o:p>
2018.03.21T16:00:39.118 0 273.15 273.05 200<o:p></o:p>
2018.03.21T16:00:39.118 1 273.2 273.05 250<o:p></o:p>
<o:p> </o:p>
Please let me know if this helps.
<o:p> </o:p>
Best regards,
Jemma
<o:p> </o:p>
From: Gully G
Sent: 21 March 2018 11:43
To: Kdb+ Personal Developers
Subject: [personal kdb+] Re: Find Aggregated Value within Column..
<o:p> </o:p>
I dont know why the my previous comment not showing the example.<o:p></o:p>
<o:p> </o:p>
@Alex please have a look at this example. I think eveyone is having a confusion as the previous example was showing only one datatime.<o:p></o:p>
<o:p> </o:p>
DateTime Price BidOrAsk Quantity Orders Ltp<o:p></o:p>
--------------------------------------------------------------<o:p></o:p>
2018.03.21T02:06:34.203 273.15 0 10 1 273.05<o:p></o:p>
2018.03.21T02:06:34.203 273.1 0 10 1 273.05<o:p></o:p>
2018.03.21T02:06:34.203 273.05 0 10 1 273.05<o:p></o:p>
2018.03.21T02:06:34.203 273 0 10 1 273.05<o:p></o:p>
2018.03.21T02:06:34.203 272.95 0 10 1 273.05<o:p></o:p>
2018.03.21T02:06:34.203 273.2 1 10 2 273.05<o:p></o:p>
2018.03.21T02:06:34.203 273.3 1 10 2 273.05<o:p></o:p>
2018.03.21T02:06:34.203 273.35 1 10 2 273.05<o:p></o:p>
2018.03.21T02:06:34.203 273.4 1 10 2 273.05<o:p></o:p>
2018.03.21T02:06:34.203 273.45 1 10 2 273.05<o:p></o:p>
<o:p> </o:p>
2018.03.21T02:06:35.203 273.15 0 10 4 273.05<o:p></o:p>
2018.03.21T02:06:35.203 273.1 0 10 4 273.05<o:p></o:p>
2018.03.21T02:06:35.203 273.05 0 10 4 273.05<o:p></o:p>
2018.03.21T02:06:35.203 273 0 10 4 273.05<o:p></o:p>
2018.03.21T02:06:35.203 272.95 0 10 4 273.05<o:p></o:p>
2018.03.21T02:06:35.203 273.2 1 10 5 273.05<o:p></o:p>
2018.03.21T02:06:35.203 273.3 1 10 5 273.05<o:p></o:p>
2018.03.21T02:06:35.203 273.35 1 10 5 273.05<o:p></o:p>
2018.03.21T02:06:35.203 273.4 1 10 5 273.05<o:p></o:p>
2018.03.21T02:06:35.203 273.45 1 10 5 273.05<o:p></o:p>
<o:p> </o:p>
The output looks like this<o:p></o:p>
DateTime Price BidOrAsk Ltp Total<o:p></o:p>
--------------------------------------------------------------<o:p></o:p>
2018.03.21T02:06:34.203 273.15 0 273.05 (10*1)+(10*1)+(10*1)+(10*1)+(10*1)=50<o:p></o:p>
2018.03.21T02:06:34.203 273.1 1 273.05 (10*2)+(10*2)+(10*2)+(10*2)+(10*2)=100<o:p></o:p>
<o:p> </o:p>
2018.03.21T02:06:35.203 273.15 0 273.05 (10*4)+(10*4)+(10*4)+(10*4)+(10*4)=200<o:p></o:p>
2018.03.21T02:06:35.203 273.1 1 273.05 . (10*5)+(10*5)+(10*5)+(10*5)+(10*5)=250<o:p></o:p>
<o:p> </o:p>
<o:p> </o:p>
Thanks,<o:p></o:p>
Gully<o:p></o:p>
<o:p> </o:p>
<o:p> </o:p>