Beginner Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOtherBeginner Programming

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 Dev Shed Forums Sponsor:
  #1  
Old April 24th, 2003, 11:38 AM
sanj sanj is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Posts: 100 sanj User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 13 h 42 m 8 sec
Reputation Power: 6
SQL Query

Hi,

I'm a little lost, I have a table of records with a column that has upto 11 different options, I would like to get a count of each option i.e.

Column names build_name, reason2

record1, misc
record2, Multiple Tasks
record3, misc
record4, Pending Date etc

what I need is a count of each type i.e.

misc = 2
Pending Date = 1
Multiple Tasks = 1 etc

Any help will be appreicated.

Regards,

Sanjay

Reply With Quote
  #2  
Old April 24th, 2003, 07:47 PM
Scorpions4ever's Avatar
Scorpions4ever Scorpions4ever is offline
Banned ;)
Dev Shed God 6th Plane (7500 - 7999 posts)
 
Join Date: Nov 2001
Location: Glendale, Los Angeles County, California, USA
Posts: 7,587 Scorpions4ever User rank is General (90000 - 100000 Reputation Level)Scorpions4ever User rank is General (90000 - 100000 Reputation Level)Scorpions4ever User rank is General (90000 - 100000 Reputation Level)Scorpions4ever User rank is General (90000 - 100000 Reputation Level)Scorpions4ever User rank is General (90000 - 100000 Reputation Level)Scorpions4ever User rank is General (90000 - 100000 Reputation Level)Scorpions4ever User rank is General (90000 - 100000 Reputation Level)Scorpions4ever User rank is General (90000 - 100000 Reputation Level)Scorpions4ever User rank is General (90000 - 100000 Reputation Level)Scorpions4ever User rank is General (90000 - 100000 Reputation Level)Scorpions4ever User rank is General (90000 - 100000 Reputation Level)Scorpions4ever User rank is General (90000 - 100000 Reputation Level)Scorpions4ever User rank is General (90000 - 100000 Reputation Level)Scorpions4ever User rank is General (90000 - 100000 Reputation Level)Scorpions4ever User rank is General (90000 - 100000 Reputation Level)Scorpions4ever User rank is General (90000 - 100000 Reputation Level) 
Time spent in forums: 1 Month 1 Day 21 h 21 m 5 sec
Reputation Power: 997
Assuming that the column "reason2" contains your options, try this statement:

SELECT COUNT(*), reason2
FROM Tablename
GROUP BY reason2
ORDER BY reason2

The ORDER BY reason2 part is optional, if you want it to order alphabetically.

Reply With Quote
  #3  
Old April 25th, 2003, 03:45 AM
sanj sanj is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Posts: 100 sanj User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 13 h 42 m 8 sec
Reputation Power: 6
Thanks very much Scorpions4ever, I went completely brain dead!

Cheers

Reply With Quote
Reply

Viewing: Dev Shed ForumsOtherBeginner Programming > SQL Query


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 5 hosted by Hostway
Stay green...Green IT