PC Review


Reply
Thread Tools Rate Thread

Counting same rows in a table

 
 
Julia82
Guest
Posts: n/a
 
      2nd Feb 2010
Hi,

How can I count same rows in a table? ex.

ID NAME
1 MARY
2 JOHN
3 MARY
4 MARY
5 JOHN

I want to know how many JOHN there are?

Thanks!
 
Reply With Quote
 
 
 
 
pietlinden@hotmail.com
Guest
Posts: n/a
 
      2nd Feb 2010
On Feb 2, 3:38*pm, Julia82 <Juli...@discussions.microsoft.com> wrote:
> Hi,
>
> How can I count same rows in a table? ex.
>
> ID * * NAME
> 1 * * * MARY
> 2 * * * JOHN
> 3 * * * MARY
> 4 * * * MARY
> 5 * * * JOHN
>
> I want to know how many JOHN there are?
>
> Thanks!


use a totals query

SELECT Name, Count(*)
FROM tblNames
ORDER BY Name
GROUP BY Name
 
Reply With Quote
 
Julia82
Guest
Posts: n/a
 
      3rd Feb 2010
I have a textbox that changes. Inside are names.

I want where the name in my query matches the name in that textbox, another
texbox displays me the count of duplicates for that user.

I don't know how to get the values from the query and put them on my form

Thanks!

"(E-Mail Removed)" wrote:

> On Feb 2, 3:38 pm, Julia82 <Juli...@discussions.microsoft.com> wrote:
> > Hi,
> >
> > How can I count same rows in a table? ex.
> >
> > ID NAME
> > 1 MARY
> > 2 JOHN
> > 3 MARY
> > 4 MARY
> > 5 JOHN
> >
> > I want to know how many JOHN there are?
> >
> > Thanks!

>
> use a totals query
>
> SELECT Name, Count(*)
> FROM tblNames
> ORDER BY Name
> GROUP BY Name
> .
>

 
Reply With Quote
 
Stuart McCall
Guest
Posts: n/a
 
      3rd Feb 2010
"Julia82" <(E-Mail Removed)> wrote in message
news:3236E5E1-70FC-4D45-B185-(E-Mail Removed)...
>I have a textbox that changes. Inside are names.
>
> I want where the name in my query matches the name in that textbox,
> another
> texbox displays me the count of duplicates for that user.
>
> I don't know how to get the values from the query and put them on my form
>
> Thanks!
>
> "(E-Mail Removed)" wrote:
>
>> On Feb 2, 3:38 pm, Julia82 <Juli...@discussions.microsoft.com> wrote:
>> > Hi,
>> >
>> > How can I count same rows in a table? ex.
>> >
>> > ID NAME
>> > 1 MARY
>> > 2 JOHN
>> > 3 MARY
>> > 4 MARY
>> > 5 JOHN
>> >
>> > I want to know how many JOHN there are?
>> >
>> > Thanks!

>>
>> use a totals query
>>
>> SELECT Name, Count(*)
>> FROM tblNames
>> ORDER BY Name
>> GROUP BY Name


First off, if you're actually using "Name" as a field name then don't. It's
a reserved word in Access and will give you trouble sooner or later. Make it
'UserName' for example.

I would use the Dcount function to obtain the number of dupes:

OtherTextbox = Dcount("UserName", "tblNames", "UserName = '" & MyTextbox &
"'")


 
Reply With Quote
 
Julia82
Guest
Posts: n/a
 
      3rd Feb 2010
Thanks Stuart, that worked fine for me. It's exactly how I wanted to work.


> "Julia82" <(E-Mail Removed)> wrote in message
> news:3236E5E1-70FC-4D45-B185-(E-Mail Removed)...
> >I have a textbox that changes. Inside are names.
> >
> > I want where the name in my query matches the name in that textbox,
> > another
> > texbox displays me the count of duplicates for that user.
> >
> > I don't know how to get the values from the query and put them on my form
> >
> > Thanks!
> >
> > "(E-Mail Removed)" wrote:
> >
> >> On Feb 2, 3:38 pm, Julia82 <Juli...@discussions.microsoft.com> wrote:
> >> > Hi,
> >> >
> >> > How can I count same rows in a table? ex.
> >> >
> >> > ID NAME
> >> > 1 MARY
> >> > 2 JOHN
> >> > 3 MARY
> >> > 4 MARY
> >> > 5 JOHN
> >> >
> >> > I want to know how many JOHN there are?
> >> >
> >> > Thanks!
> >>
> >> use a totals query
> >>
> >> SELECT Name, Count(*)
> >> FROM tblNames
> >> ORDER BY Name
> >> GROUP BY Name

>
> First off, if you're actually using "Name" as a field name then don't. It's
> a reserved word in Access and will give you trouble sooner or later. Make it
> 'UserName' for example.
>
> I would use the Dcount function to obtain the number of dupes:
>
> OtherTextbox = Dcount("UserName", "tblNames", "UserName = '" & MyTextbox &
> "'")
>
>
> .
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ACCESS IS COUNTING BLANK EXCEL ROWS AS RECORDS IN A LINKED TABLE CHaney Microsoft Access External Data 1 12th Nov 2009 08:10 PM
Counting bold cells in table rows John Microsoft Excel Worksheet Functions 2 11th Jun 2008 02:52 AM
Counting Last n Rows in Expanding Table jmacvicar@autranscanada.com Microsoft Excel Misc 9 29th Oct 2007 03:41 PM
Pivot Table - Is counting all rows jblair@era-usa.com Microsoft Excel Misc 1 16th Mar 2007 08:12 PM
Counting rows in an SQL table =?Utf-8?B?QXJ0?= Microsoft VB .NET 7 20th Jun 2006 03:26 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:15 PM.