Sorting of queries with a "group by"

It appears that queries that have a “group by” clause always return aresult that’s sorted on the grouped columns. Why is that?q)t:(a:10?100;b:10?100;c:10?8)q)ta b c-------2 84 439 63 064 93 249 54 182 38 240 97 188 88 277 58 330 68 217 45 5q)select a,b by c from tc| a b-| -----------------------0| ,39 ,631| 49 40 54 972| 64 82 88 30 93 38 88 683| ,77 ,584| ,2 ,845| ,17 ,45The group primitive returns a different order, which seems morenatural:q)group t.c4| ,00| ,12| 2 4 6 81| 3 53| ,75| ,9Is there any way to get grouped queries to *not* sort by default?

Hello,

Is this what you’re looking for?

`c xgroup t

Regards,

Fintan.


On Jun 9, 2011 8:54 AM, andyturk <andyturk@gmail.com> wrote:

It appears that queries that have a “group by” clause always return a
result that’s sorted on the grouped columns. Why is that?

q)t:(a:10?100;b:10?100;c:10?8)
q)t
a b c

2 84 4
39 63 0
64 93 2
49 54 1
82 38 2
40 97 1
88 88 2
77 58 3
30 68 2
17 45 5
q)select a,b by c from t

c a b
0 ,39 ,63
1 49 40 54 97
2 64 82 88 30 93 38 88 68
3 ,77 ,58
4 ,2 ,84
5 ,17 ,45

The group primitive returns a different order, which seems more
natural:

q)group t.c
4| ,0
0| ,1
2| 2 4 6 8
1| 3 5
3| ,7
5| ,9

Is there any way to get grouped queries to *not* sort by default?


Submitted via Google Groups