Solved

Help with ms access query

Posted on 2014-04-14
9
315 Views
Last Modified: 2014-04-14
Hi, experts.
I have a simple database.
I have two queries:
qryRec_Last---------------shows how many projects received
qryPro_Last---------------shows how many projects completed

select Count(qryRec_Last_1.projectId) AS Count FROM qryRec_Last_1
------->60
select Count(qryPro_Last_1.projectId) AS FROM qryPro_Last_1;
------->30

i want to write a query showing:
Received             Completed           %
60                        30                        50%

Thanks
0
Comment
Question by:rfedorov
9 Comments
 
LVL 84

Assisted Solution

by:Scott McDaniel (Microsoft Access MVP - EE MVE )
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 50 total points
Comment Utility
Are they stored queries?

If so, then create a third, and include those two in the query design, and join them on the appropriate field if needed.

Now create another field that calculates them:

CompletePct: qryRec_Last_1.Count / qryPro_Last_1.Count

Note that you have NOT used an alias in qryPro_Last_1, so you'd need to do that:

select Count(qryPro_Last_1.projectId) AS Count FROM qryPro_Last_1;
0
 

Author Comment

by:rfedorov
Comment Utility
Thank you for the fast respond, but i did not get ... I do not have a proble with calculating the %, i can not figure out how to put them on the same line:
Received             Completed           %
60                        30                        50%
0
 
LVL 119

Expert Comment

by:Rey Obrero
Comment Utility
what is the name of the table where based your two queries?

post the sql of the two queries.
0
 

Author Comment

by:rfedorov
Comment Utility
select Count(qryRec_Last_1.projectId) AS Count FROM qryRec_Last_1
select Count(qryPro_Last_1.projectId) AS FROM qryPro_Last_1;
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 119

Expert Comment

by:Rey Obrero
Comment Utility
what is the name of the table where based your two queries?

post the sql of the two queries.  
"qryRec_Last_1"

"qryPro_Last_1"
0
 

Author Comment

by:rfedorov
Comment Utility
' qryPro_Last_1
SELECT
DISTINCT DataExtr.StatusCreatedByUser, DataExtr.StartStatus, DataExtr.EndStatus, DataExtr.StartDate, DataExtr.projectId, Format([StartDate],"mm/dd/yyyy") AS DatePortion
FROM DataExtr
WHERE (((DataExtr.StatusCreatedByUser) In ("GR","Cs","Jr")) AND ((DataExtr.StartStatus)="15 - Project Completion") AND ((DataExtr.EndStatus)="Invoice Approved") AND ((Format([StartDate],"mm/dd/yyyy")) Between "01/06/2014" And "01/10/2014") AND ((Format([StartDate],"yyyy"))="2014"))
ORDER BY DataExtr.StartDate, DataExtr.projectId;



'qryRec_Last_1
SELECT DataExtr.projectId, DataExtr.EndStatus, TimeValue([StartDate]) AS [Time], DataExtr.StartDate, IIf(TimeValue([StartDate])<=#12/30/1899 15:0:0#,[StartDate],DateAdd("h",12,[StartDate])) AS New, Format([StartDate],"mm/dd/yyyy") AS JustDate
FROM DataExtr
WHERE (((DataExtr.EndStatus)="06a - Implementer Verified Measures") AND ((Format([StartDate],"mm/dd/yyyy")) Between "01/02/2014" And "01/10/2014"))
ORDER BY DataExtr.projectId, DataExtr.StartDate DESC;
0
 
LVL 26

Assisted Solution

by:skullnobrains
skullnobrains earned 50 total points
Comment Utility
select
  (select Count(qryRec_Last_1.projectId) AS Count FROM qryRec_Last_1) as received
  ,(select Count(qryPro_Last_1.projectId) AS FROM qryPro_Last_1) as completed
  completed * 100 / received & ' %' as percentage
0
 

Author Comment

by:rfedorov
Comment Utility
If i copy exactly what you put, i am getting the error...
0
 
LVL 119

Accepted Solution

by:
Rey Obrero earned 400 total points
Comment Utility
try this query



Select sum(iif(A.[Source]="Rec",1,0)) as Received, sum(iif(A.[Source]="Pro",1,0)) as Completed,
([Received]/[Completed]) as CompletePct
From
(
select [projectId], 'Pro' as Source from qryPro_Last_1
Union all
select [projectId], 'Rec' as Source from qryRec_Last_1
) as A
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
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…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …

728 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

11 Experts available now in Live!

Get 1:1 Help Now