Solved

Obtaining Sums in Access

Posted on 2012-03-29
7
323 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
  • 3
  • 2
  • 2
7 Comments
 
LVL 51

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 119

Expert Comment

by:Rey Obrero
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 119

Assisted Solution

by:Rey Obrero
Rey Obrero earned 175 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 51

Accepted Solution

by:
HainKurt earned 325 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Today's users almost expect this to happen in all search boxes. After all, if their favourite search engine juggles with tens of thousand keywords while they type, and suggests matching phrases on the fly, why shouldn't they expect the same from you…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

910 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

21 Experts available now in Live!

Get 1:1 Help Now