In the last episode (Mar 16), Bob Cooper said:
> I am working with MySQL ver 5.1 on a Ubuntu Linux x86_64. I am new to
> both SQL and MySQL. I have been able to query out most of the data I
> need from my tables without any issues but his one has stumped me.
>
> I am trying to query data associate
>I want to pull distinct rows (there could be as many as 30 rev's
>per date) and the data on that row. so.. I'd like to get the following
GROUP BY groups by aggregate value, not by row. Use a WHERE clause to
return a row corresponding to the value of a column.
PB
Justin wrote:
hmm.. that work
hmm.. that worked.. but I guess I forgot to mention.. I don't need the value
of the rev.. I wanted to return that row.. like.. let me put some more info
date revtext desc
-
20070315 1
1) ORDER BY is executed after GROUP BY;
2) In ORDER BY don't use columns that aren't in GROUP BY, unless it's an
aggregated value;
Your query can be rewritten as:
select date
, max(rev) as max_rev
from table
group
by date
order
by max_rev desc
2007/3/17, Justin <[EMAIL PROTECTED]>:
I've got an issue with group / order by.. here's what I'm wondering..
simple table..
date | rev
--
20070315 1
20070315 2
20070316 1
20070316 2
Query I'm running
SELECT * FROM `table` GROUP BY `date` order by `rev` DESC
I wo
Hi,
I am working with MySQL ver 5.1 on a Ubuntu Linux x86_64.
I am new to both SQL and MySQL.
I have been able to query out most of the data I need from my tables
without any issues but his one has stumped me.
I am trying to query data associated with specific dates.
The dates are not sequential
I don't know if this is optimal or not, but it does work...
DROP TABLE IF EXISTS `x`;
CREATE TABLE `x` (
`id` int(11) default NULL,
`path1` varchar(10) default NULL,
`display` varchar(10) default NULL,
`value` varchar(10) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
insert into x va