Wrox Programmer Forums
|
SQL Language SQL Language discussions not specific to a particular RDBMS program or vendor.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Language section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 27th, 2004, 02:35 PM
Authorized User
 
Join Date: Jul 2003
Posts: 98
Thanks: 0
Thanked 0 Times in 0 Posts
Default Getting Counts

Hello Everyone and thanks for your help in advance. I am having trouble with a query. I need to return one occurrence of an individual's name and ID number along with the count for the number of times this person appears in the table. I have tried a Group By clause, but to the best of my knowledge, would require the Group By part to have both NAME and ID in the grouping, which doesn't seem to return what I want. I have tried Select Distinct, but can't figure out how to get the count. Any help on this topic would be greatly appreciated. Thanks.

 
Old October 27th, 2004, 03:45 PM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 303
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I apologize if I have not understand you question. Is this you are looking for..?

SELECT ID,Name,Count(Name) As Total
FROM Table
GROUP BY ID,Name
 
Old October 27th, 2004, 04:01 PM
Authorized User
 
Join Date: Jul 2003
Posts: 98
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Perfect! Thanks for the help.






Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding COUNTs fizzerchris SQL Server 2005 3 February 6th, 2007 05:16 PM
Join for two different counts on same view thenoseknows SQL Server 2000 0 January 21st, 2007 06:37 PM
join two counts field erin SQL Language 2 October 29th, 2003 04:50 AM
How to HavePrint Counts amar Pro VB 6 0 July 13th, 2003 10:05 AM
Get Counts harpua Classic ASP Databases 3 June 10th, 2003 12:45 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.