Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access Count function Question 1

Status
Not open for further replies.

Cordury2

Technical User
Jan 22, 2005
55
US
I apologize in advance for the lame question.

I have one table where I want to count the number of transactions over certain amounts (25, 50, 75).

I have a query that is counting the TOTAL number of Transactions but when I enter ">25" in the criteria box, I receive a "Data Type Mismatch in Criteria Expression" error.

Is this something that has to be done through SQL?
 
how are ya Cordury2 . . .

Remove both double quotes:
Code:
[blue]    [red][b]"[/b][/red]>25[red][b]"[/b][/red][/blue]

Calvin.gif
See Ya! . . . . . .
 
Thank you for the response TheAceMan1. I tried that and it returns the total number of transactions in the table not matter what amount I type after the greater than symbol. I checked the table and that field is a number (not sure if that would matter though).
 
Hi Randy,
The dollar amount is in the Sales column and that is where I am placing the criteria.
 
Here is the SQL

SELECT ByTran.CDay, Count(ByTran.Sales) AS CountOfSales
FROM ByTran
GROUP BY ByTran.CDay
HAVING (((Count(ByTran.Sales))>50));
 

Something like...
Code:
SELECT ByTran.CDay, Count(ByTran.Sales) AS CountOfSales
FROM ByTran
GROUP BY ByTran.CDay
[b][COLOR=red]WHERE ByTran.Sales > 25[/color][/b]


Randy
 
You wanted this ?
SELECT CDay, Count(Sales) AS CountOfSales
FROM ByTran
WHERE Sales>50
GROUP BY CDay

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Syntax Error (missing operator) in query expression 'ByTran.CDay WHERE By.Tran.Sales > 25'
 
Now if I do this:
Code:
SELECT ByTran.CDay, ByTran.Sales
FROM ByTran
GROUP BY ByTran.CDay, ByTran.Sales
HAVING (((ByTran.Sales)>"50"));

it returns all records over 50 which I could throw into Excel and a Pivot table but I am looking to get it all through Access.
 
Yours
Code:
WHERE By.Tran.Sales > 25
Corrected
Code:
WHERE ByTran.Sales > 25


Randy
 
Randy,
First off, thank you for your patience.

But the SQL is
Code:
SELECT ByTran.CDay, Count(ByTran.Sales) AS CountOfSales
FROM ByTran
GROUP BY ByTran.CDay
WHERE ByTran.Sales > 25

and I am stillg getting the same error.
 
PHV

Code:
SELECT bytran.CDay, Count(bytran.Sales) AS CountOfSales
FROM ByTran
WHERE bytran.Sales>50
GROUP BY bytran.CDay

I am sorry, I did try your suggestion and the following error occured:
"Data type mismatch criteria in expression
 
PHV gave you a corrected version of my suggestion. USE HIS. My WHERE and GROUP BY clauses are reversed and won't work.

What is the data type of your Sales field?

In your 14:13 post, you say
Syntax Error (missing operator) in query expression 'ByTran.CDay WHERE By.Tran.Sales > 25'
Look at the section in red. You have an extra DOT.

Randy
 
It was Number but I changed it to Text. Now when I try and change it back to Number and save I get a Not enough disk space or memory error so it is stuck at text.

I am a nightmare, I know.
 
For text you need quotes around the criteria. However, you really need to change it back to a number data type. Have you tried doing a Compact and Repair?


Randy
 
The Compact and Repair won't work either. I am working on getting the original table.
 
I got the original table and PV's code seems to be working.

Again, thank you both so much for your time and patience as well as expertise.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top