Solved

How to use 'Count' in Access for a field of type string

Posted on 2014-12-02
1
172 Views
Last Modified: 2014-12-02
Dear All,

I have a table with the following fields.  I'm trying to count the number of times the same string appears in ItemID, the same string in ModelID for each LocationID.

ID (Number)
ItemID (String)
LocationID (Number)
ModelID (String)

I've tried:

SELECT Count([Table1].ItemID) AS ItemCount, Count([Table1].ModelID) AS ModelCount, [Table1].LocationID
FROM 
(SELECT DISTINCT [Table1].LocationID FROM  [Table1] );

Open in new window




The error states Query does not include LocationID as part of Aggregate function.  

Thanks
0
Comment
Question by:AndyC1000
1 Comment
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 500 total points
ID: 40477813
try

SELECT Count([Table1].ItemID) AS ItemCount, Count([Table1].ModelID) AS ModelCount, [Table1].LocationID
FROM  [Table1]
Group By  [Table1].LocationID
0

Featured Post

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question