subquery with critera and count?

  • Thread starter Thread starter danheskett
  • Start date Start date
D

danheskett

I have a table that looks like this:

+-------------+
| Statements |
+-------------+-----+
| ID Primary Key |
+-------------------+
| RecKey Text(128) |
+-------------------+

The RecKey is indexed but duplicates are allowed. I want to produce a
query that shows a list of each unique RecKey with the number of times
the RecKey is present in the table;

I was thinking:

SELECT ID, RecKey, RecKey as R, Count(SELECT ID FROM Statements Where
RecKey=R)

But of course this quite right; for one it doesn't work, I can't figure
out to make Access recognize R as the value, and not a literal;
additionall, if this did work, it would not show only unique values of
RecKey.

Anyone have some tips on what missing link I am without?
 
If the RecKey values you want only have an "R" in that field...
RecKey = "R"
Given that the field is 128 in length I'm thinking you may have RecKey
values like R1423, R9392876, etc...
In that case...
RecKey Like "R" & "*"
should do it.
hth
Al Camp
Candia Computer Consulting - Candia NH
http://home.comcast.net/~cccsolutions
 
select RecKey, count(*) as Frequency from Statements group by RecKey

-Duy
 
SELECT RecKey, Count(*) AS RecKeyCount
FROM Statements
GROUP BY RecKey
 
Thanks Guys!

I was making it very difficult, when it's not.

Doug and Duy's solutions both worked very well.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top