Oracle Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesOracle Development

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 February 23rd, 2005, 07:44 PM
GolfingTea GolfingTea is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2005
Posts: 2 GolfingTea User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 22 m 18 sec
Reputation Power: 0
Producing a list from A-Z, showing amount of members with that initial

Hi everyone,

I know this is a very tricky question but any recomended approaches would be much appretiated

Im using Oracle8i / SQL and have a table of members (table: Members), the column I'm working with here is Lname...

Im trying to find how to develop a query that lists for every letter of the alphabet how many members' last names start with this letter.

So the list will have 2 columns whereby the 1st contains letters of the alphabet, with the 2nd containing numbers representing how many members last name (Lname) starts with that particular letter.

So far I have:

select SUBSTR(Lname,0,1), count(*)
from Member group by Lname;

but this is way to simple and returns:

S Count
- ------
c 1
c 1
c 1
p 1
f 1
f 1

Anyone have any ideas?

Thanks in advance

Reply With Quote
  #2  
Old February 24th, 2005, 12:50 AM
suresh1977 suresh1977 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2005
Posts: 13 suresh1977 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 16 m 57 sec
Reputation Power: 0
Just Change the Query as given below and you should have the answer.

select SUBSTR(Lname,1,1), count(*)
from Member group by SUBSTR(Lname,1,1);


Quote:
Originally Posted by GolfingTea
Hi everyone,

I know this is a very tricky question but any recomended approaches would be much appretiated

Im using Oracle8i / SQL and have a table of members (table: Members), the column I'm working with here is Lname...

Im trying to find how to develop a query that lists for every letter of the alphabet how many members' last names start with this letter.

So the list will have 2 columns whereby the 1st contains letters of the alphabet, with the 2nd containing numbers representing how many members last name (Lname) starts with that particular letter.

So far I have:

select SUBSTR(Lname,0,1), count(*)
from Member group by Lname;

but this is way to simple and returns:

S Count
- ------
c 1
c 1
c 1
p 1
f 1
f 1

Anyone have any ideas?

Thanks in advance

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesOracle Development > Producing a list from A-Z, showing amount of members with that initial


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