BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

SQL Problem: ORDER-ing by COUNT(something)

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder Databases (ADO)
View previous topic :: View next topic  
Author Message
Vladimir Stefanovic
Guest





PostPosted: Wed Jul 06, 2005 8:06 am    Post subject: SQL Problem: ORDER-ing by COUNT(something) Reply with 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
Viatcheslav V. Vassiliev
Guest





PostPosted: Wed Jul 06, 2005 11:28 am    Post subject: Re: SQL Problem: ORDER-ing by COUNT(something) Reply with quote



....
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





PostPosted: Wed Jul 06, 2005 12:29 pm    Post subject: Re: SQL Problem: ORDER-ing by COUNT(something) Reply with quote



Quote:
ORDER BY COUNT(Field)

I was blind Wink Thanks a lot...



--
Best regards,
Vladimir Stefanovic



Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder Databases (ADO) All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.