473,406 Members | 2,816 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Help out with a difficult query?

I'm working on migrating about 2000 documents from one knowledge
management system to another and am having a hard time with 1 report.
Each record has (among other things) 1 of 3 units (categories)
assigned to it (EBI, Network or Mainframe) and a few different
statuses (which for arguments sake we can boil down to 3). I want the
report to look like this (the numbers are just examples):

Complete Incomplete Total
EBI 10 20 30
Network 15 15 30
Mainframe 20 10 30

Right now I have 3 queries set up. 1 calculates the total for each
unit, another calculates the complete for each unit, and the third
calculates the difference and displays my final table above.

There must be an easier (and more elegant) way though. Any ideas would
be greatly appreciated.

For those interested, here's the details:

The table I'm pulling from is tblKSMaster.
I'm counting the timestamp field becuase I know each record will have
a value in that field.

Here's the queries:

qrySubDataComplete:
SELECT tblKSMaster.AssignedUnit, Count(tblKSMaster.Timestamp) AS
CountOfTimestamp
FROM tblKSMaster
WHERE (((tblKSMaster.Status)="REWRITE_DONE" Or
(tblKSMaster.Status)="EDIT_DONE" Or (tblKSMaster.Status)="INVALID" Or
(tblKSMaster.Status)="PUBFOLDER"))
GROUP BY tblKSMaster.AssignedUnit
HAVING (((tblKSMaster.AssignedUnit)="network" Or
(tblKSMaster.AssignedUnit)="ebi" Or
(tblKSMaster.AssignedUnit)="mainframe"))
ORDER BY tblKSMaster.AssignedUnit;
qrySubDataTotal:
SELECT tblKSMaster.AssignedUnit, Count(tblKSMaster.Timestamp) AS
CountOfTimestamp
FROM tblKSMaster
GROUP BY tblKSMaster.AssignedUnit
HAVING (((tblKSMaster.AssignedUnit)="network" Or
(tblKSMaster.AssignedUnit)="ebi" Or
(tblKSMaster.AssignedUnit)="mainframe"))
ORDER BY tblKSMaster.AssignedUnit;
qryTotalCompleteByTeam:
SELECT qrySubDataComplete.AssignedUnit,
qrySubDataComplete.CountOfTimestamp AS Complete,
[qrySubDataTotal].[Countoftimestamp]-[qrySubDataComplete].[countoftimestamp]
AS Incomplete, qrySubDataTotal.CountOfTimestamp AS Total
FROM qrySubDataComplete INNER JOIN qrySubDataTotal ON
qrySubDataComplete.AssignedUnit = qrySubDataTotal.AssignedUnit;

Thanks!

Keith
Nov 12 '05 #1
1 1330
Keith Work wrote:
I'm working on migrating about 2000 documents from one knowledge
management system to another and am having a hard time with 1 report.
Each record has (among other things) 1 of 3 units (categories)
assigned to it (EBI, Network or Mainframe) and a few different
statuses (which for arguments sake we can boil down to 3). I want the
report to look like this (the numbers are just examples):

Complete Incomplete Total
EBI 10 20 30
Network 15 15 30
Mainframe 20 10 30

Right now I have 3 queries set up. 1 calculates the total for each
unit, another calculates the complete for each unit, and the third
calculates the difference and displays my final table above.

There must be an easier (and more elegant) way though. Any ideas would
be greatly appreciated.

For those interested, here's the details:

The table I'm pulling from is tblKSMaster.
I'm counting the timestamp field becuase I know each record will have
a value in that field.

Here's the queries:

qrySubDataComplete:
SELECT tblKSMaster.AssignedUnit, Count(tblKSMaster.Timestamp) AS
CountOfTimestamp
FROM tblKSMaster
WHERE (((tblKSMaster.Status)="REWRITE_DONE" Or
(tblKSMaster.Status)="EDIT_DONE" Or (tblKSMaster.Status)="INVALID" Or
(tblKSMaster.Status)="NVALID"))
GROUP BY tblKSMaster.AssignedUnit
HAVING (((tblKSMaster.AssignedUnit)="network" Or
(tblKSMaster.AssignedUnit)="ebi" Or
(tblKSMaster.AssignedUnit)="mainframe"))
ORDER BY tblKSMaster.AssignedUnit;


SELECT tblKSMaster.AssignedUnit, Sum(1) AS TotalCount, _
Sum(IIF(Instr("REWRITE_DONE,EDIT_DONE,INVALID,PUBF OLDER",[Status]) > 0;1,0)
As Complete,
Sum(IIF(Instr("REWRITE_DONE,EDIT_DONE,INVALID,PUBF OLDER",[Status]) = 0;1,0)
As InComplete
FROM tblKSMaster
WHERE (((tblKSMaster.AssignedUnit)="network" Or
(tblKSMaster.AssignedUnit)="ebi" Or
(tblKSMaster.AssignedUnit)="mainframe"))
GROUP BY tblKSMaster.AssignedUnit
ORDER BY tblKSMaster.AssignedUnit;

This should work....or should be close to what you want.

Nov 12 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: majsen | last post by:
Hi, I have problem running this query. It will time out for me... My database are small just about 200 members. I have a site for swaping appartments (rental). my query should look for match in...
3
by: AMD Desktop | last post by:
Here is the table: CREATE TABLE ( IDENTITY (1, 1) NOT NULL , NOT NULL , NOT NULL , NOT NULL CONSTRAINT DEFAULT (0), NOT NULL , NOT NULL ) ON
28
by: stu_gots | last post by:
I have been losing sleep over this puzzle, and I'm convinced my train of thought is heading in the wrong direction. It is difficult to explain my circumstances, so I will present an identical...
1
by: rsarath | last post by:
Hello, I have the following setup and I would appreciate any help in improving the performance of the query. BigTable: Column1 (indexed) Column2 (indexed) Column3 (no index) Column4 (no...
14
by:  | last post by:
having a spot of trouble writing this one. if you are so inclined and have a moment, i'd really appreciate your insight. i have what amounts to a purchase order type of setup...a descriptive...
8
by: Xu, Wei | last post by:
Hi, I have wrote the following sql sentence.Do you have comments to improve the performance.I have created all the indexed. But it's still very slow.Thanks The primary key is proj_ID and...
2
by: schoultzy | last post by:
Hello Everyone, This is probably a simple fix so be kind when/if you reply. The query below retrieves information for individuals based on a column named ATTRIB_DEF, and assorted other columns;...
4
by: yanjie.ma | last post by:
Hi, I've got a two part question on table and form design (sorry for the length but it takes a bit to explain). Our sales department uses a look-up table to help the them select the best...
4
by: n | last post by:
Hello! Here is a problem I hope you can point me to a solution. It Problem: A teacher needs to know which lesson to teach. A school has a curriculum with 26 lessons, A-Z. For a given class,...
5
by: Justin | last post by:
Here's my XML: <?xml version="1.0" ?> <AppMode Type="Network"> <CurrentFolder Path="c:\tabs"> <Tabs> <FilePath>tabs\Justin.tab</FilePath> <FilePath>tabs\Julie.tab</FilePath> *****There could...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.