Solved

Help with ms access query

Posted on 2014-04-14
9
320 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

 

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 27

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
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.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

710 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