Microsoft SQL Server
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsDatabaseMicrosoft SQL Server

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old June 25th, 2004, 10:10 AM
nepala nepala is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 20 nepala User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
sql query string help?

Dear friends...

I need a sql query string,....

I have database with names as follows..

ABC
ABC
DEF
FRG
FRG
FRG
FRG
DEF
ABC

Now i need a sql query string to show the data by following way.
FRG 4
ABC 3
DEF 2
please help

regards

Ananda

Reply With Quote
  #2  
Old June 25th, 2004, 10:46 AM
Memnoch's Avatar
Memnoch Memnoch is offline
Unholy Moderator
ASP Free God 14th Plane (11500 - 11999 posts)
 
Join Date: Oct 2003
Location: In hell, where did you think?
Posts: 11,776 Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level) 
Time spent in forums: 3 Weeks 5 Days 8 h 27 m 42 sec
Reputation Power: 470
do this
Code:
SELECT name, Count(name) as 'Count'
FROM TableName
GROUP BY name
ORDER BY 'Count' DESC

Reply With Quote
  #3  
Old June 25th, 2004, 11:10 AM
nepala nepala is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 20 nepala User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
dear sir:

Thank you for your help.

I got the answer but it is not in desending order..

ABC 3
DEF 2
FRG 4


Please help

regards
Ananda

Reply With Quote
  #4  
Old June 25th, 2004, 11:59 AM
nepala nepala is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 20 nepala User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thank you it is working now

instead of ORDER by 'Count' DESC

i changed this to ORDER BY count(name) DESC

Thank you


Website design ecommerce and data entry

Reply With Quote
  #5  
Old June 27th, 2004, 07:03 AM
nepala nepala is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 20 nepala User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
need more help sql?

Dear friends


thanks for solving my problem .

I need a query to show the result as follow


table has two fields

user Name
A ABC
B DEF
B DEF
A ABC
C ABC


Now i want sql query to generate following out put
ABC 2
DEF 1


I hope you people understand what i need, expecting for your kind help

regards
Nepala

Reply With Quote
Reply

Viewing: ASP Free ForumsDatabaseMicrosoft SQL Server > sql query string help?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT