Re: Group By / Order BY

2007-03-17 Thread Peter Brawley
70316 2this is version 2 This was the first one today but agian we needed to update. does that make sense? - Original Message - From: "Olexandr Melnyk" <[EMAIL PROTECTED]> To: "Justin" <[EMAIL PROTECTED]>; Sent: Saturday, March 17,

Re: Group By / Order BY

2007-03-17 Thread Justin
0316 2this is version 2 This was the first one today but agian we needed to update. does that make sense? - Original Message - From: "Olexandr Melnyk" <[EMAIL PROTECTED]> To: "Justin" <[EMAIL PROTECTED]>; Sent: Saturday, March 17, 200

Re: Group By / Order BY

2007-03-17 Thread Olexandr Melnyk
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]>:

Group By / Order BY

2007-03-17 Thread Justin
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

Re: GROUP BY ORDER BY

2005-05-31 Thread Michael Stassen
GROUP BY returns grouped columns and aggregate functions, not rows. You are grouping on history.person_id, so it makes no sense to select any column that does not have a unique value for each history.person_id. Indeed, other systems wouldn't even allow selecting non-grouped columns

GROUP BY ORDER BY

2005-05-31 Thread René Fournier
I'm trying to SELECT the most recent record in a table for each person record in another table. Here's what I have so far: SELECT history.*, persons.person_short_name, persons.person_long_name FROM history, persons WHERE

Re: GROUP BY, ORDER BY clauses

2005-03-30 Thread Michael Genereux
es read as follows: > > SELECT *, *, * FROM * > WHERE * > GROUP BY * ORDER BY * > > Also, does GROUP BY only work on fields that are strings (i.e. > CHAR, VARCHAR, TEXT, etc.). Thanks in advance. > > - Asad > > -- > MySQL General Mailing List > For list archive

Re: GROUP BY, ORDER BY clauses

2005-03-30 Thread Asad Habib
UP BY and ORDER BY used in > > conjunction with one another? I have tried to execute several queries > > with both these clauses but the result set I get is different from what > I > > expect. My queries read as follows: > > > > SELECT *, *, * FROM * > > WHER

Re: GROUP BY, ORDER BY clauses

2005-03-30 Thread SGreen
I > expect. My queries read as follows: > > SELECT *, *, * FROM * > WHERE * > GROUP BY * ORDER BY * > > Also, does GROUP BY only work on fields that are strings (i.e. > CHAR, VARCHAR, TEXT, etc.). Thanks in advance. > > - Asad > I hope you don't expect your q

GROUP BY, ORDER BY clauses

2005-03-30 Thread Asad Habib
Does MySQL 4.1 support the use of GROUP BY and ORDER BY used in conjunction with one another? I have tried to execute several queries with both these clauses but the result set I get is different from what I expect. My queries read as follows: SELECT *, *, * FROM * WHERE * GROUP BY * ORDER BY

Group By Order By problem

2004-04-30 Thread Erich Beyrent
Hi all, I am trying to get a bunch of results, group them by category, and then order each group of categories. My query is thus: SELECT l.CatalogNumber, l.MP3Name, l.PDFLink, l.PDFName, l.Title, p.PublisherName, c.ComposerLname,

Re: group by & order by rand() problem

2004-04-02 Thread Alessandro Astarita
Alle 21:57, giovedì 1 aprile 2004, Michael Stassen ha scritto: > You could probably accomplish this with a variant of the MAX-CONCAT > trick > . > Something like: > >SELECT user_id, > SUBSTRING(MAX(CONCAT(TRUNCATE(RAND

Re: group by & order by rand() problem

2004-04-01 Thread Michael Stassen
Right. You're grouping by user_id and throwing in title, and you're hoping to influence which of the titles is chosen to go with user_id, but as title is neither part of your group nor part of an aggregate function, its value is undefined. See the manual for an explanation

RE: group by & order by rand() problem

2004-03-31 Thread m.pheasant
-Original Message- From: Dathan Vance Pattishall [mailto:[EMAIL PROTECTED] Sent: Thursday, April 01, 2004 7:16 AM To: [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: RE: group by & order by rand() problem Try seeding your rand. > -Original Message- > From: [EMAIL PROTECTED] [mai

RE: group by & order by rand() problem

2004-03-31 Thread [EMAIL PROTECTED]
> Try seeding your rand. Tried. It doesn't work. The select shows always the same records but in different order: SELECT * FROM banners GROUP BY user_id ORDER BY RAND(); first call ++-+---+ | id | user_id | title | ++-+---+ | 1 | 1 |

RE: group by & order by rand() problem

2004-03-31 Thread Dathan Vance Pattishall
Try seeding your rand. > -Original Message- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] > Sent: Wednesday, March 31, 2004 12:57 PM > To: [EMAIL PROTECTED] > Subject: group by & order by rand() problem > > I have this table: > &g

group by & order by rand() problem

2004-03-31 Thread [EMAIL PROTECTED]
I have this table: mysql> select * from banners; ++-+---+ | id | user_id | title | ++-+---+ | 1 | 1 | first banner | | 2 | 1 | second banner | | 3 | 2 | third banner | | 4 | 2 | forth banner | | 5 | 2 | f

Re: GROUP BY/ORDER BY Problem

2003-10-05 Thread Ed Smith
The SQL specification does allow aggregates in the ORDER BY. Does mySQL have any plans to add such functionality (or at least add it to its list of things it doesn't do)? The problem with the solution of ordering by an alias is that I may not necessarily want the thing I'm ordering by to be in th

Re: GROUP BY/ORDER BY Problem

2003-10-04 Thread Paul DuBois
At 5:52 -0700 10/3/03, Ed Smith wrote: Why doesn't the following work: mysql> CREATE TABLE dog(id integer, breed char(20), age integer, weight integer) ; mysql> SELECT breed, MIN(age) -> FROM dog -> GROUP BY breed -> ORDER BY MIN(age); ERROR : Invalid use of group function I don't

GROUP BY/ORDER BY Problem

2003-10-03 Thread Ed Smith
Why doesn't the following work: mysql> CREATE TABLE dog(id integer, breed char(20), age integer, weight integer) ; mysql> SELECT breed, MIN(age) -> FROM dog -> GROUP BY breed -> ORDER BY MIN(age); ERROR : Invalid use of group function but this does mysql> SELECT breed, MIN(age)

So simple, yet wonderful:-) Re: New Group By, order by question

2003-07-24 Thread Martin Moss
Thanks to everyone who Helped, Regards Marty - Original Message - From: "Joseph Bueno" <[EMAIL PROTECTED]> To: "Martin Moss" <[EMAIL PROTECTED]> Cc: <[EMAIL PROTECTED]> Sent: Thursday, July 24, 2003 3:56 PM Subject: Re: New Group By, order by quest

Re: New Group By, order by question

2003-07-24 Thread Joseph Bueno
select order by abs(field) desc; Hope this helps, Joseph Bueno Martin Moss wrote: All, I have a question about grouping numbers. Lets say I have 10 records each containing a numeric value:- 1 2 3 5 10 -1 -2 -3 -4 -5 What I wish to do is to select the records from the database but group the

Re: New Group By, order by question

2003-07-24 Thread Nils Valentin
Hi Martin, I understand the ABS() function is used for this. Best regards Nils Valentin Tokyo/Japan 2003年 7月 24日 木曜日 23:42、Martin Moss さんは書きました: > All, > > I have a question about grouping numbers. > > Lets say I have 10 records each containing a numeric value:- > > 1 > 2 > 3 > 5 > 10 > -1 > -

New Group By, order by question

2003-07-24 Thread Martin Moss
All, I have a question about grouping numbers. Lets say I have 10 records each containing a numeric value:- 1 2 3 5 10 -1 -2 -3 -4 -5 What I wish to do is to select the records from the database but group them like this :- e.g. by the highest value (ASC or DESC) regarldess of whether the value

RE: GROUP BY ORDER BY

2003-07-24 Thread Gary Broughton
EMAIL PROTECTED] Subject: Re: GROUP BY ORDER BY "Gary Broughton" <[EMAIL PROTECTED]> wrote: > > I wonder if someone could help with what I assume is a simple query > using GROUP and/or ORDER statements (something I struggle to get to > grips with). I am trying to get a li

Re: GROUP BY ORDER BY

2003-07-24 Thread Victoria Reznichenko
"Gary Broughton" <[EMAIL PROTECTED]> wrote: > > I wonder if someone could help with what I assume is a simple query > using GROUP and/or ORDER statements (something I struggle to get to > grips with). I am trying to get a list of users who have posted to a > forum by number of posts descending, b

Re: GROUP BY ORDER BY

2003-07-24 Thread John Wunderly
try this: order by 1 desc -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]

GROUP BY ORDER BY

2003-07-24 Thread Gary Broughton
Hi I wonder if someone could help with what I assume is a simple query using GROUP and/or ORDER statements (something I struggle to get to grips with). I am trying to get a list of users who have posted to a forum by number of posts descending, but am unable to find the right statement to do i

Re: sql query(group by + order by)

2002-06-10 Thread Bhavin Vyas
by clause is causing undesired results. - Original Message - From: "lorenzo.kh" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Monday, June 10, 2002 6:53 PM Subject: sql query(group by + order by) > Hi, > I got a table named patient_treatment_history &g

sql query(group by + order by)

2002-06-10 Thread lorenzo.kh
Hi, I got a table named patient_treatment_history Below is some of the records inside the table. patient_id,treatment_date,charges 1014,2002-01-28,20 1001,2002-02-02,100 1026,2002-04-08,74 1001,2002-04-15,85 1014,2002-05-05,50 1030,2002-05-16,125 1030,2002-06-18,180 1001,2002-06-25,125 I try to

group by, order by, temporary table

2001-12-19 Thread Christian Andersson
Hi there, I'm back with yet some questions about group by/order by in mysql.. My first question is how group by is beeing done if I have have columns in the select query that is not in the "group by" statement. Dring many test with 3.23-42 (Myisam tables) I found out that the