Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 How do i get the details of each user

Author  Topic 

afrika
Master Smack Fu Yak Hacker

2706 Posts

Posted - 2005-10-29 : 04:54:15
Hello,
I have a phone book table thus :


phoneID int
username varchar(20)
phone_number varchar(55)


now we have loads of users, with lots of entires in their phone book.

How do i write an efficient SQL script to show what each user has in his phone book like thus


Username      Number of entries
afrika 523
madihivana 3030
Spirit1 4302
Kristen 5333
rockmoose 2284


etc

Sounds a bit tricky, I am wondering if i let the work be done on my web page with repeated regions or on the sql ?

Afrika

sachinsamuel
Constraint Violating Yak Guru

383 Posts

Posted - 2005-10-29 : 08:26:02
You want user name with the number of entries in there phone book?

Select Username , Count(Username) as 'Number of entries'
from Phone_Book
group by Username

Hope the above query helps.

Regards
Sachin Samuel
Go to Top of Page
   

- Advertisement -