Solved

Help with ms access query

Posted on 2014-04-14
9
317 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
ID: 39999272
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
ID: 39999300
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 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 39999392
what is the name of the table where based your two queries?

post the sql of the two queries.
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 

Author Comment

by:rfedorov
ID: 39999403
select Count(qryRec_Last_1.projectId) AS Count FROM qryRec_Last_1
select Count(qryPro_Last_1.projectId) AS FROM qryPro_Last_1;
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 39999524
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
ID: 39999550
' 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
ID: 39999560
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
ID: 39999668
If i copy exactly what you put, i am getting the error...
0
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 400 total points
ID: 39999705
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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

'Between' is such a common word we rarely think about it but in SQL it has a very specific definition we should be aware of. While most database vendors will have their own unique phrases to describe it (see references at end) the concept in common …
Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

777 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