?
Solved

Obtaining Sums in Access

Posted on 2012-03-29
7
Medium Priority
?
331 Views
Last Modified: 2012-03-29
I have a query that i am trying to obtain data for a specific program, but the column i have to work with lists the program within job title naming conventions.  I have figured out how to separate all job titles within this program from other programs, but am looking for a whole number so i can obtain additional total numbers for login, usage and duration.  Below is the code i have so far and attached is a description of what it looks like and my desired output.  

If i could find a way to combine all Dept Names with APS into one category, then the counts should give me the sums that i require.  The word APS isn't always consistent in the names.  For most it is at the beginning, for others it is integrated in the body.  The other option is to total the two count columns, then i can divide those whole numbers to get a usage percent.  I know you can total these within a report but would prefer to do in a query so the report focuses on those 3 numbers.  

SELECT employeeinfo.DEPTNAME, Count(dragon.LastUser) AS TotalUsers, Count(dragon.LastLoginName) AS TotalLogins
FROM employeeinfo INNER JOIN dragon ON employeeinfo.LOGNAME = dragon.LastLoginName
GROUP BY employeeinfo.DEPTNAME
HAVING (((employeeinfo.DEPTNAME) Like "*APS*"));
APS-Utilization.xls
0
Comment
Question by:jsawicki
[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
  • 3
  • 2
  • 2
7 Comments
 
LVL 57

Expert Comment

by:HainKurt
ID: 37784230
try this:

SELECT 'APS' as DEPTNAME, Count(dragon.LastUser) AS TotalUsers, Count(dragon.LastLoginName) AS TotalLogins
FROM employeeinfo INNER JOIN dragon ON employeeinfo.LOGNAME = dragon.LastLoginName
where (((employeeinfo.DEPTNAME) Like "*APS*"));
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 37784267
try this query

SELECT IIF(Instr([employeeinfo].[DEPTNAME],"ASP")>0,"ASP",Null) as DName, Count(dragon.LastUser) AS TotalUsers, Count(dragon.LastLoginName) AS TotalLogins
FROM employeeinfo INNER JOIN dragon ON employeeinfo.LOGNAME = dragon.LastLoginName
Where  Instr([employeeinfo].[DEPTNAME],"ASP")>0
GROUP BY  IIF(Instr([employeeinfo].[DEPTNAME],"ASP")>0,"ASP",Null)


better if you can upload a copy of the db with the tables
0
 
LVL 120

Assisted Solution

by:Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1) earned 700 total points
ID: 37784323
correction


SELECT IIF(Instr([employeeinfo].[DEPTNAME],"APS")>0,"APS",Null) as [Dept Name], Count(dragon.LastUser) AS TotalUsers, Count(dragon.LastLoginName) AS TotalLogins
FROM employeeinfo INNER JOIN dragon ON employeeinfo.LOGNAME = dragon.LastLoginName
GROUP BY  IIF(Instr([employeeinfo].[DEPTNAME],"APS")>0,"APS",Null)
HAVING (((IIf(InStr([employeeinfo].[DeptName],"Aps")>0,"APS",Null)) Is Not Null))
0
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 

Author Comment

by:jsawicki
ID: 37784383
HainKurt:  It worked, but what if i wanted to go one step further and add a second set of results so it shows all of CPS.  Can that be done within the same query.  Check the attachment for my output.  the APS info is accurate, CPS is what i would like and not sure if that is possible.  Seems like i might have to do a crosstab query to get these results.  

Capricorn:  I would love to post the database with tables, but not sure if i am allowed since it is state agency info.  Your query didn't retrieve any results.
example.xls
0
 

Author Comment

by:jsawicki
ID: 37784391
Cap:  your correction worked and gave the exact same results.  Do you have any ideas for my second suggestion?
0
 
LVL 57

Accepted Solution

by:
HainKurt earned 1300 total points
ID: 37784428
maybe simple form:

SELECT 'APS' as DEPTNAME, Count(dragon.LastUser) AS TotalUsers, Count(dragon.LastLoginName) AS TotalLogins
FROM employeeinfo INNER JOIN dragon ON employeeinfo.LOGNAME = dragon.LastLoginName
where (((employeeinfo.DEPTNAME) Like "*APS*"))
union
SELECT 'CPS' as DEPTNAME, Count(dragon.LastUser) AS TotalUsers, Count(dragon.LastLoginName) AS TotalLogins
FROM employeeinfo INNER JOIN dragon ON employeeinfo.LOGNAME = dragon.LastLoginName
where (((employeeinfo.DEPTNAME) Like "*CPS*"))
0
 

Author Closing Comment

by:jsawicki
ID: 37784523
Thanks to both, now i undestand the purpose of a union.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
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…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Suggested Courses

752 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