[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Visual Basic SQL Count Query

Posted on 2004-03-31
2
Medium Priority
?
469 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 43

Accepted Solution

by:
TimCottee earned 1000 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

650 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