List:Brisbane MySQL Users Group« Previous MessageNext Message »
From:Arjen Lentz Date:August 10 2005 2:47am
Subject:Re: [SPAM] Re: Sort by count
View as plain text  
Hi Scott, Mark,

On Wed, 2005-08-10 at 10:26, Scott McClintock wrote:
> Two simple solutions:
> 
> a)
> SELECT count(software_name) software_count, software_name.....
> order by software_count
> 
> b)
> 
> .... order by 1 .....

That's evil. I believe the SQL standards committee is considering
ripping that out.


You can repeat the COUNT(software_name) in the ORDER BY clause, but
using the column alias as shown in solution (a) is by far the best and
most readable.

Regards,
Arjen.


> Mark Unwin wrote:
> > I have a MySQL query such - 
> > SELECT count(software_name), software_name, software_version from
> > software WHERE software_name NOT LIKE '%hotfix%' AND
> > software_no_detect_date = '1111-11-11' group by software_name ORDER BY
> > software_name LIMIT 1,50
> > 
> > Now, this works fine - sorting by software_name.
> > How can I sort by count(software_name) ?
> > I tried using sort count(software_name), just to see, naturally, it
> > failed.
> > Any ideas ?
> > 
> > TIA,
> > Mark Unwin.
> > 
> > 
> >
> *************************************************************************************************
> > This message and any attachments, or any part
> > of it is intended solely for the named addressee.  
> > 
> > Reading, printing, distribution, storing, commercialising
> > or acting on this transmission or any information it contains, by anyone other
> than the addressee, is prohibited. If you have received this message in error, please
> destroy all copies and notify 
> > Qld Police Credit Union Ltd on +61 7 3008 4444 or by replying to the sender.
> > 
> > This message may contain legally privileged and
> > confidential information, and/or copyright material
> > of QPCU or third parties.
> > 
> > QPCU is not responsible for any changes made
> > to a document other than those made by QPCU,
> > or for the effect of the changes on the document's meaning.
> > You should only re-transmit, distribute or commercialise
> > the material if you are authorised to do so.
> > 
> > Any views expressed in this message are
> > those of the individual sender.  You may not rely on this message as advice
> unless subsequently confirmed by fax or letter signed by an Officer or Director of QPCU,
> or 
> > an Authorised Representative QPCU.
> > 
> > QPCU advises that this e-mail and any attached files should be scanned to detect
> viruses.  QPCU accepts no liability for loss or damage (whether caused by negligence or
> not) resulting from the use of any attached files.
> > 
> > Information regarding Privacy can be found at the QPCU web site. (
> www.qpcu.org.au )
> > 
> > General Advice Warning
> > 
> > Any advice has been prepared without taking into account your particular
> objectives, financial situation or needs.  For that reason, before acting on the advice
> you should consider the appropriateness of the advice having regard to your own
> objectives, financial situation and needs.  Where the advice relates to the acquisition,
> or possible acquisition, of a particular financial product, you should obtain a Product
> Disclosure Statement relating to the product and consider the Product Disclosure Statement
> before making any decision about whether to acquire the product.
> >
> *************************************************************************************************
> > 
> > 
> 
> -- 
> ========================================================================
> Scott McClintock                    Email: smcclintock@stripped
> General Manager                     Phone: 07 3842 8888
> Technical Solutions                   Fax: 07 3842 8899
> NetOptions Pty Ltd                    Web: http://www.netoptions.com.au
> Brisbane, Australia
> ------------------------------------------------------------------------
> ............... Simple Solutions in a Complex World ....................
> ========================================================================
-- 
Arjen Lentz, Community Relations Manager
MySQL AB, www.mysql.com

MySQL related blogs @ http://www.planetmysql.org/


Thread
Sort by countMark Unwin10 Aug
  • [SPAM] Re: Sort by countScott McClintock10 Aug
    • Re: [SPAM] Re: Sort by countArjen Lentz10 Aug
      • Re: [SPAM] Re: Sort by countScott McClintock10 Aug