Solved

Obtaining Sums in Access

Posted on 2012-03-29
7
322 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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 

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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

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…
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 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…

743 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

13 Experts available now in Live!

Get 1:1 Help Now