|
 |
access_asp thread: SQL Query Difficulty
Message #1 by "Young, Ashley" <Ashley.Young@c...> on Wed, 23 Oct 2002 16:27:16 -0400
|
|
Hi, everyone.
I'm having a bit of trouble trying to construct an SQL query. What I want
the query to do is count the number of times a call was made by a certain
person. The query pulls from a table called tblCompanies and from a field
named "calledby".
I want the query to display a listing of the names in the calledby field
and how many times that name appears. I tried constructing a count query
like this:
select count(calledby) as Count where calledby='name'
But that didn't work because I'd have to have 20 different recordsets to
get the information I want. I'm sure somebody has a good way to do this. Any
help is appreciated and details are always good.
Thanks in advance!
--Ashley
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.377 / Virus Database: 211 - Release Date: 7/15/2002
Message #2 by "Ken Schaefer" <ken@a...> on Thu, 24 Oct 2002 11:22:33 +1000
|
|
SELECT
CalledBy,
COUNT(CalledBy)
FROM
YourTableNameHere
GROUP BY
CalledBy
will output something like:
John Smith 20
Jane Doe 17
Person Three 42
...
Person n 19
Cheers
Ken
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From: "Young, Ashley" <Ashley.Young@c...>
Subject: [access_asp] SQL Query Difficulty
: Hi, everyone.
:
: I'm having a bit of trouble trying to construct an SQL query. What I want
: the query to do is count the number of times a call was made by a certain
: person. The query pulls from a table called tblCompanies and from a field
: named "calledby".
:
: I want the query to display a listing of the names in the calledby field
: and how many times that name appears. I tried constructing a count query
: like this:
:
: select count(calledby) as Count where calledby='name'
:
: But that didn't work because I'd have to have 20 different recordsets to
: get the information I want. I'm sure somebody has a good way to do this.
Any
: help is appreciated and details are always good.
:
: Thanks in advance!
:
: --Ashley
:
: ---
: Outgoing mail is certified Virus Free.
: Checked by AVG anti-virus system (http://www.grisoft.com).
: Version: 6.0.377 / Virus Database: 211 - Release Date: 7/15/2002
:
:
Message #3 by "Larry Woods" <larry@l...> on Wed, 23 Oct 2002 18:38:25 -0700
|
|
Ashley,
Try this...
SELECT calledby, Count(calledby) AS Count
FROM tablename GROUP BY calledby
Larry Woods
> -----Original Message-----
> From: Young, Ashley [mailto:Ashley.Young@c...]
> Sent: Wednesday, October 23, 2002 1:27 PM
> To: Access ASP
> Subject: [access_asp] SQL Query Difficulty
>
>
> Hi, everyone.
>
> I'm having a bit of trouble trying to construct an
> SQL query. What I want
> the query to do is count the number of times a call
> was made by a certain
> person. The query pulls from a table called
> tblCompanies and from a field
> named "calledby".
>
> I want the query to display a listing of the names
> in the calledby field
> and how many times that name appears. I tried
> constructing a count query
> like this:
>
> select count(calledby) as Count where calledby='name'
>
> But that didn't work because I'd have to have 20
> different recordsets to
> get the information I want. I'm sure somebody has a
> good way to do this. Any
> help is appreciated and details are always good.
>
> Thanks in advance!
>
> --Ashley
>
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.377 / Virus Database: 211 - Release Date:
> 7/15/2002
>
>
|
|
 |