On Thu, Sep 15, 2011 at 07:00:43AM +0800, Mohd Radzi Ibrahim scratched on the wall: > > On 15-Sep-2011, at 2:55 AM, Magnus Thor Torfason wrote: > > > > > I then ran a query grouping employees by job: > > > > > select ename, job from emp group by job; > > "ENAME", "JOB" > > ============== > > "FORD", "ANALYST" > > "MILLER", "CLERK" > > "CLARK", "MANAGER" > > "KING", "PRESIDENT" > > "TURNER", "SALESMAN" > > > > Now, I get a list of the jobs, and a random selection of employees. I would > > have expected an error here. Of course, my actual > > It's not random selection, it's the last one from the list.
Yes, but as always, "last" is a relative thing. Result sets have no set or defined ordering without an ORDER BY, and you cannot use an ORDER BY in this case, as it is applied after the GROUP BY operation. Adding an index, or future query optimizations may cause the order to change. -j -- Jay A. Kreibich < J A Y @ K R E I B I.C H > "Intelligence is like underwear: it is important that you have it, but showing it to the wrong people has the tendency to make them feel uncomfortable." -- Angela Johnson _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users