I have a Union Query that is tied directly to a report and one field needs to be modified. The "CountOfAttended" results in a number that needs to have the "Programs.walk-ins" field added to it. This seems like it ought to be a simple thing but every work around I've tried has brought up a variety of errors. The SQL code looks like this (CountOfAttended is highlighted): SELECT Programs.Name, Programs.[Date Start], Programs.[Date End], Count(Programs__Registered_Participants.Attended) AS CountOfAttended, MonthName(DatePart("m",[Date End])) AS ProgMonth, DatePart("yyyy",[Date End]) AS ProgYear
FROM Programs INNER JOIN (Participants INNER JOIN Programs__Registered_Participants ON Participants.[Participant ID] = Programs__Registered_Participants.Participant_ID) ON Programs.[Program ID] = Programs__Registered_Participants.Program_ID
WHERE (((Programs__Registered_Participants.Attended)=Yes ))
GROUP BY Programs.Name, Programs.[Date Start], Programs.[Date End], DatePart("m",[Date End]), DatePart("yyyy",[Date End])
ORDER BY Programs.Name
UNION SELECT Programs__Tickered_Attendance_ONLY.Name, Programs__Tickered_Attendance_ONLY.Date, Programs__Tickered_Attendance_ONLY.Date, Programs__Tickered_Attendance_ONLY.Attendees, MonthName(DatePart("m",[Date])) AS ProgMonth, DatePart("yyyy",[Date]) AS ProgYear
FROM Programs__Tickered_Attendance_ONLY;
I'm new to SQL of any kind and was handed this somewhat large Access project when a staff member left so I'm taking something over in midstream and a bit lost on how to deal with this problem. Thanks again for any suggestions
2 2649 ADezii 8,834
Recognized Expert Expert
I have a Union Query that is tied directly to a report and one field needs to be modified. The "CountOfAttended" results in a number that needs to have the "Programs.walk-ins" field added to it. This seems like it ought to be a simple thing but every work around I've tried has brought up a variety of errors. The SQL code looks like this (CountOfAttended is highlighted): SELECT Programs.Name, Programs.[Date Start], Programs.[Date End], Count(Programs__Registered_Participants.Attended) AS CountOfAttended, MonthName(DatePart("m",[Date End])) AS ProgMonth, DatePart("yyyy",[Date End]) AS ProgYear
FROM Programs INNER JOIN (Participants INNER JOIN Programs__Registered_Participants ON Participants.[Participant ID] = Programs__Registered_Participants.Participant_ID) ON Programs.[Program ID] = Programs__Registered_Participants.Program_ID
WHERE (((Programs__Registered_Participants.Attended)=Yes ))
GROUP BY Programs.Name, Programs.[Date Start], Programs.[Date End], DatePart("m",[Date End]), DatePart("yyyy",[Date End])
ORDER BY Programs.Name
UNION SELECT Programs__Tickered_Attendance_ONLY.Name, Programs__Tickered_Attendance_ONLY.Date, Programs__Tickered_Attendance_ONLY.Date, Programs__Tickered_Attendance_ONLY.Attendees, MonthName(DatePart("m",[Date])) AS ProgMonth, DatePart("yyyy",[Date]) AS ProgYear
FROM Programs__Tickered_Attendance_ONLY;
I'm new to SQL of any kind and was handed this somewhat large Access project when a staff member left so I'm taking something over in midstream and a bit lost on how to deal with this problem. Thanks again for any suggestions
I think that your Summary Statistic (Programs__Registered_Participants.Attended) AS CountOfAttended may have to be referenced in the initial GROUP BY Clause. Hope this helps.
ADezii
I think that your Summary Statistic (Programs__Registered_Participants.Attended) AS CountOfAttended may have to be referenced in the initial GROUP BY Clause. Hope this helps.
ADezii
I explained poorly, the query I posted was working properly, the problem comes in when I try to perform a SUM. For example, it seems to me that this: Sum(Count(Programs__Registered_Participants.Attend ed), Programs.walk-ins) AS CountOfAttended
In place of this:
Count(Programs__Registered_Participants.Attended) AS CountOfAttended
but when I do that it tells me that subqueries can't be used in this fashion. So that's what I'm trying to figure out, how to add one field to another within this query.
thanks again
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Bryan Zash |
last post by:
When querying a bit field, I am encountering a problem with MS SQL
Server returning a larger number of records for a table than the
actual number of records that exist within that table.
For...
|
by: Robin Tucker |
last post by:
I'm considering adding domain integrity checks to some of my database table
items. How does adding such constraints affect SQL Server performance? For
example, I have a simple constraint that...
|
by: Wendy Powley |
last post by:
I have a subform which represents a 1:N relationship with the main
form. I would like to be able to read values from an external file,
fill the subform with the values read & allow the user to...
|
by: bdt513 |
last post by:
I am trying to extract the values from a query using VBA.
Specifically, I want to concatenate all the values of the "rosEmail"
field from query "qselRosterEmailList" into one string (strEmails). I...
|
by: Viorel |
last post by:
Adding new row with default values.
In order to insert programmatically a new row into a database table, without
direct "INSERT INTO" SQL statement, I use the well-known DataTable.NewRow,...
| |
by: Rudy |
last post by:
Hi all,
I know this is easy, just can't seem to get it. I have a windows form, and
a text box, with a value already in it. I need to add that value to a table.
It's just one value, so the entire...
|
by: Pierre Barbier de Reuille |
last post by:
Please, note that I am entirely open for every points on this proposal
(which I do not dare yet to call PEP).
Abstract
========
This proposal suggests to add symbols into Python.
Symbols...
|
by: Jeff Boes |
last post by:
I hope this helps someone else ... I had struggled some time ago with
attempts to get a rank of values query to work, but then I gave up and
set it aside. I had another reason to attack it, and in...
|
by: john |
last post by:
In my form (table A) I have subform (table B (only 2 fieds: ID and App_name)
where table A -Table B are linked 1XM. To be able to add a record in the
subform I want to use a lookup form since the...
|
by: OllyJ |
last post by:
Hi guys, probably an easy one for you.
I know how to limit a row source sor a combo on a form (setting unique values). The problem i'm having is that the query is the record source for a...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |