Solved

Visual Basic SQL Count Query

Posted on 2004-03-31
2
442 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

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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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 process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

810 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