Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Combine Queries

Status
Not open for further replies.

xeb

Technical User
Nov 14, 2003
81
US
Hi:

I have the following two queries:

SELECT Sum(IIf(Month(shDates.SchoolDays)=9,1,0)) AS September
FROM shDates;

SELECT First(month(shDates.SchoolDays)) As Month, Count(shDates.SchoolDays) As SchoolDays
FROM shDates
GROUP BY month(shdates.SchoolDays);

How do I combine one of them with my other query so it can all go on one report? This is the other query...

SELECT shData.MonthEarned, Sum(shData.HonorRoll) AS SumofHonorRoll, Sum(shData.StudentoftheWeek) AS SumOfStudentoftheWeek, Sum(shData.StudentoftheMonth) AS SumOfStudentoftheMonth, Count((DCount("[StudentPublicName]","shMain"))) AS CountofStudents
FROM shData
GROUP BY shData.MonthEarned;

Thanks,

xeb
 
Hi xeb

I'll guess that you are not looking for a UNION query, but rather to just have the disparate results show up in the same report.

Look at subreports, where you can use each query as the record source for seperate reports, then combine the seperate reports into a main (parent) report.

If it is your intention to have the queries return related records, then you will need to include in each of the queries whatever field(s) serving as the primary key.

Off the subject: in your first query you use September as a criteria. This means that next month someone will have to modify the query. Better to pass the month as a parameter or variable.

Come back if you need more help.

Cheers,
Bill
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top