 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Vladimir Stefanovic Guest
|
Posted: Wed Jul 06, 2005 8:06 am Post subject: SQL Problem: ORDER-ing by COUNT(something) |
|
|
Hi,
How can I ORDER this SQL by 'Cnt', and not by 'Field'?
(when I try 'ORDER BY Cnt', I got an error)
SELECT Field, COUNT(Field) AS Cnt
FROM Table
WHERE SomeCondition
GROUP BY Field
ORDER BY Field
Best regards,
Vladimir Stefanovic
|
|
| Back to top |
|
 |
Viatcheslav V. Vassiliev Guest
|
Posted: Wed Jul 06, 2005 11:28 am Post subject: Re: SQL Problem: ORDER-ing by COUNT(something) |
|
|
....
ORDER BY COUNT(Field)
In your query - GROUP BY Field ORDER BY COUNT(Field) - count will always be
1.
//------------------------------------------
Regards,
Vassiliev V. V.
http://www.managed-vcl.com - using .Net objects in Delphi for Win32 +
ADO.Net
http://www.oledbdirect.com - The fastest way to access MS SQL Server,
MS Jet (Access) and Interbase (through OLEDB)
"Vladimir Stefanovic" <antivari (AT) po (DOT) sbb.co.yu> сообщил/сообщила в новостях
следующее: news:42cb9104$1 (AT) newsgroups (DOT) borland.com...
| Quote: |
Hi,
How can I ORDER this SQL by 'Cnt', and not by 'Field'?
(when I try 'ORDER BY Cnt', I got an error)
SELECT Field, COUNT(Field) AS Cnt
FROM Table
WHERE SomeCondition
GROUP BY Field
ORDER BY Field
Best regards,
Vladimir Stefanovic
|
|
|
| Back to top |
|
 |
Vladimir Stefanovic Guest
|
Posted: Wed Jul 06, 2005 12:29 pm Post subject: Re: SQL Problem: ORDER-ing by COUNT(something) |
|
|
| Quote: | ORDER BY COUNT(Field)
|
I was blind Thanks a lot...
--
Best regards,
Vladimir Stefanovic
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|