grouping sorting ordering
am 04.04.2011 13:55:30 von (Sándor Halász) hsvI wrote this query, making use of MySQL s permissive 'GROUP BY', for to keep only one record with a given value of 'Email', quite indifferent which record is kept:
select REPLACE(eMail, '- ', '') AS Email, IFNULL(foreignKey, '') AS "Foreign Key", "Full Name", "List Membership"
from PHPLIST2 AS Z
WHERE eMail IS NOT NULL
GROUP by Z.email
It quite satisfactorily does that, but it is ordered not by the new 'Email', but by that ere the REPLACing. If I change the name, the outcome is in order by the first field:
select REPLACE(eMail, '- ', '') AS Q, IFNULL(foreignKey, '') AS "Foreign Key", "Full Name", "List Membership"
from PHPLIST2 AS Z
WHERE eMail IS NOT NULL
GROUP by Q
Natheless, I want 'Email' for both names. How can I make it take 'Email' after 'AS' for the grouping? (The outcome is the same whether I write 'Z.email' or 'Email'.)
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=gcdmg-mysql-2@m.gmane.org