Re: Optimizing GROUP BY and ORDER BY

2008-07-25 Thread Michael Stearne
On Fri, Jul 25, 2008 at 12:35 PM, Arthur Fuller <[EMAIL PROTECTED]> wrote: > ORDER BY implies a sort of the result set. I don't think there is any way > around that. I guess so. What I am doing is to just run the query once per day and store the results in memcache. Michael > > Arthur > > On Fr

Re: Optimizing GROUP BY and ORDER BY

2008-07-25 Thread Rob Wultsch
On Fri, Jul 25, 2008 at 12:27 AM, Michael Stearne <[EMAIL PROTECTED]> wrote: > I have a query: > > SELECT Country, COUNT( Country ) AS Cnt > FROM properties WHERE ( > Country != 'USA' AND > Country != 'US' AND > Country != 'Unit' AND > Country != 'United States' > AND

Optimizing GROUP BY and ORDER BY

2008-07-25 Thread Michael Stearne
I have a query: SELECT Country, COUNT( Country ) AS Cnt FROM properties WHERE ( Country != 'USA' AND Country != 'US' AND Country != 'Unit' AND Country != 'United States' AND Country != ' ' AND Country IS NOT NULL ) GROUP BY Country ORDER BY Cnt DESC LIMIT 8 that gets the top 8 non-US countries fr

Re: Optimization on query with WHERE, GROUP BY and ORDER BY

2003-12-05 Thread Chris Elsworth
Hello, On Fri, Dec 05, 2003 at 12:02:05PM +0100, Martin Gillstr?m wrote: > > The table can look something like this: > row_id INT PRIMARY KEY > where_column SET('a','b','c') > groupby_column VARCHAR(255) > orderby_column DATE > .. more rows that I need to fetch with the select. > This is what I

Optimization on query with WHERE, GROUP BY and ORDER BY

2003-12-05 Thread Martin Gillström
Hi, I have a table with about 500 000 rows and need to execute a query with first a WHERE then a GROUP BY and then ORDER BY all on different columns is their any way to optimize this? The table can look something like this: row_id INT PRIMARY KEY where_column SET('a','b','c') groupby_column VAR

Re: GROUP BY and ORDER BY not working together

2003-05-29 Thread Peter Fleck
At 3:50 PM -0400 5/28/03, Keith C. Ivey wrote: On 28 May 2003 at 14:17, Peter Fleck wrote: SELECT grants.grantid, grants.refnum, dates.subdaynum FROM grants, dates WHERE (grants.agency = "NIH-O" AND grants.grantid = dates.grantid) GROUP BY grants.grantid ORDER BY dates.yearday; This giv

Re: GROUP BY and ORDER BY not working together

2003-05-29 Thread Keith C. Ivey
On 28 May 2003 at 14:17, Peter Fleck wrote: > SELECT grants.grantid, grants.refnum, dates.subdaynum FROM grants, > dates >WHERE (grants.agency = "NIH-O" AND grants.grantid = dates.grantid) >GROUP BY grants.grantid ORDER BY dates.yearday; > > This gives me one listing per grant but they ar

Re: GROUP BY and ORDER BY not working together

2003-05-29 Thread James Moe
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On Wed, 28 May 2003 14:17:55 -0500, Peter Fleck wrote: The results you wanted and the results you get were not very clear. Some examples would have gone a long way. >SELECT grants.grantid, grants.refnum, dates.subdaynum FROM grants, dates > WHER

GROUP BY and ORDER BY not working together

2003-05-29 Thread Peter Fleck
I'm having some trouble with a GROUP BY clause. My database has a main table ('grants') with grant listings. Each grant has one listing, including a grantid column. A second table ('dates') holds date info about each grant. 'grants' to 'dates' is one-to-many as a grant can have several submissi

Re: query problem with GROUP BY and ORDER BY

2002-06-02 Thread Philip Spradling
On Sat, 01 Jun 2002 11:58:38 +0200 Claire Forchheimer <[EMAIL PROTECTED]> wrote: I know the answer to the first part at least. I think you want to use two columns in the order by clause, and leave out the group by clause. As in: select * from tbl order by apt, name; I'm afraid its too late a

query problem with GROUP BY and ORDER BY

2002-06-01 Thread Claire Forchheimer
Hi all, I have a table including two colums: names and apartment numbers: apt #| name -- 1 | Smith Joe 1 | Smith Anne 2 | Doe Richard 3 | Svensen Mike 3 | Brant Liza I need to get a list in alphabetical order, but with people in the same apt keept together: Brant, S

Re: group by and order by

2001-05-14 Thread Bob Hall
>I have a table with texts, all of different type, I have field named >type to know which is which. What I would want is with one SQL query >select the latest from each type, but this query... > >select id, headline, type from texts group by type order by date; > >will give the first of each typ

group by and order by

2001-05-11 Thread Sandman
I have a table with texts, all of different type, I have field named type to know which is which. What I would want is with one SQL query select the latest from each type, but this query... select id, headline, type from texts group by type order by date; will give the first of each type. I wo