Wrox Programmer Forums
|
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access 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 January 12th, 2007, 09:16 AM
Authorized User
 
Join Date: Jan 2007
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default Count the same items

Hi,
does some one knows how to show the most used items items from a table??
like:

yellow
green
blue
yellow
yellow
green

the thing i have to see is the most used color. In this case it is yellow.

Please help me.


 
Old January 12th, 2007, 12:23 PM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

SELECT TOP 1 tblYourTableName.Color, Count(tblYourTableName.Color) AS CountOfColor
FROM tblYourTableName
GROUP BY tblYourTableName.Color;

In your case, this will return

Color CountOfColor
yellow 3

HTH

mmcdonal
 
Old January 15th, 2007, 06:20 AM
Authorized User
 
Join Date: Jan 2007
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks it works!!!






Similar Threads
Thread Thread Starter Forum Replies Last Post
For repeated ComboBoxes Count Selected Items Borhani Excel VBA 1 March 24th, 2008 06:49 PM
Count the same items stasnikov Access VBA 1 January 12th, 2007 12:27 PM
listbox control items count shows 0. vikram_bendre ASP.NET 2.0 Basics 5 August 24th, 2006 08:37 AM
Count, sum, count a value, return records CongoGrey Access 1 April 18th, 2005 02:25 PM
displaying 6 items only having 20 items Lakshmi KS VB Components 1 February 17th, 2004 10:34 AM





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