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
!= ' '
AND Country IS NOT NULL )
GROUP BY Country
ORDER BY Cnt
DESC LIMIT
This is a costly query
I suggest that this is not a well normalized. I suggest that at a
minium you should be using a 'Country' which would include a distinct
entry for each country.
If such a table exists a column
25, 2008 at 4: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 Country != ' ' AND Country IS NOT NULL ) GROUP
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
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 have
, 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 are not sorted
correctly. From what I can figure out, mysql is only looking at the
first occurence of a grant
(grants.agency = NIH-O AND grants.grantid = dates.grantid)
GROUP BY grants.grantid
ORDER BY dates.yearday;
The results are sorted within the groups by yearday. However, the groups themselves
are not in any particular order. Try this:
order by grants.grantid,dates.yearday;
- --
jimoe
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
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
I need to get a list in alphabetical order, but with people in the same
apt keept together:
Brant, Svensen
Doe
Smith, Smith
The difficulty is to get people living in the same apt grouped together.
SELECT * FROM tbl GROUP BY apt ORDER BY name - will drop the second
name
found
, Svensen
Doe
Smith, Smith
The difficulty is to get people living in the same apt grouped together.
SELECT * FROM tbl GROUP BY apt ORDER BY name - will drop the second
name
found in each apt!
(The result would be this list:
Brant
Doe
Smith)
I've been banging my head black and blue over this query
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
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
13 matches
Mail list logo