Solved

Obtaining Sums in Access

Posted on 2012-03-29
7
324 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 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
Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

 

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
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…

776 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