Solved

Obtaining Sums in Access

Posted on 2012-03-29
7
326 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 51

Expert Comment

by:Huseyin KAHRAMAN
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 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
The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

 

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:
Huseyin KAHRAMAN 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

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

I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

740 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