Solved

Visual Basic SQL Count Query

Posted on 2004-03-31
2
436 Views
Last Modified: 2013-12-25
Hi, I am trying to get the following information, using an Access Database:

sql = "SELECT A.1, A.2, A.3 FROM A"
           
But I also want to get a Count from B Where A.1 = B.1

If I try this:

sql = "SELECT A.1, A.2, A.3, count(B.2) As Number FROM A,B WHERE A.1 = B.1"

I am trying to get a result of all A.1, A.2, A.3 and a count of B.2 where A.1 = B.1

The error I get is:
“you tried to execute a query that does not include the specified expression ‘userName’ as part of an aggregate function"

Any help would be great!

Thanks!
0
Comment
Question by:DOCOOGIE
2 Comments
 
LVL 43

Accepted Solution

by:
TimCottee earned 250 total points
ID: 10724391
Hi DOCOOGIE,

You could do:

Select A.1, A.2, A.3, (Select Count(*) From B Where A.1 = B.1) As Number From A

Tim Cottee
Brainbench MVP for Visual Basic
http://www.brainbench.com
0
 

Author Comment

by:DOCOOGIE
ID: 10724462
Tim,

Thanks!  You are a lifesaver!
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

708 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now