473,396 Members | 2,076 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,396 software developers and data experts.

Counts query access

35 32bit
Is it possible to have counts from two different tables in one query? I tried this and it worked, but I have duplicate rows with the same count numbers.
May 10 '10 #1
3 1566
NeoPa
32,556 Expert Mod 16PB
Yes it is. What are you trying to do? It's very possible that what you want is not supported but your question is very open.
May 10 '10 #2
rhonda6373
35 32bit
The business scenario is that I have multiple test cases for single template IDs. The template IDs are stored in one table and the test cases are stored in another table. The common field is the TemplateID.

I need a count of both the number of TemplateIDs as well as the total count of test cases in a single query.

I was attempting to get a Pivot table with both counts and that are also spliced by status.

I am open to any other solutions.
May 10 '10 #3
NeoPa
32,556 Expert Mod 16PB
I would create a GROUP BY query that has another GROUP BY query as a subquery (See Subqueries in SQL).

Something like :
Expand|Select|Wrap|Line Numbers
  1. SELECT   Count([TemplateID] AS TemplateIDs
  2.        , Sum([TestCases]) AS AllTestCases
  3.  
  4. FROM
  5.     (
  6.     SELECT   [TemplateID]
  7.            , Count([TestCase]) AS TestCases
  8.     FROM     [tblTestCase]
  9.     GROUP BY [TemplateID]
  10.     )
I would create a GROUP BY query that has another GROUP BY query as a subquery (See Subqueries in SQL).

Something like :
Expand|Select|Wrap|Line Numbers
  1. SELECT   Count([TemplateID] AS TemplateIDs
  2.        , Sum([TestCases]) AS AllTestCases
  3.  
  4. FROM
  5.     (
  6.     SELECT   [TemplateID]
  7.            , Count([TestCase]) AS TestCases
  8.     FROM     [tblTestCase]
  9.     GROUP BY [TemplateID]
  10.     )
There is no GROUP BY clause in the main query as all records are grouped together.
May 11 '10 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Cady Steldyn | last post by:
Example: Date | ItemCode | Stock_In_qty | Stock_Out_qty | Bal_qty ------------------------------------------------------------------ 12/09/2003 | A100 | 20 | 0 ...
15
by: PMBragg | last post by:
Thank you in advance. I'm trying to pull all inventory items from December of the previous year back to 4 years for my accountant. I know this can be done, but I'm drawing a blank. I've tried; ...
6
by: PMBragg | last post by:
Thank you everyone that helped me with my DateSerial question. I really do appreciate it. Now my accountant has told I need to pull the inventory for just the year I'm depreciating. Is there a way...
13
by: IndianaJonesWB | last post by:
I have an Access Project as a front end for a SQL DB. I have a master copy and distribute copies of it to my other users. I would like to display a revision count on the first Main Form so that...
2
by: P Adhia | last post by:
Hi, I am trying to understand why following simple query is running very slow (33 hours) select ROW_ID , a.CREATED , a.CREATED_BY , a.LAST_UPD , a.LAST_UPD_BY
7
by: rguarnieri | last post by:
Hi! I'm trying to create a query with a boolean expression like this: select (4 and 1) as Value from Table1 this query return always -1, but when I make the same calculation in visual...
5
by: Jakob32 | last post by:
Hi I'm trying to link information from a query in another Access database to my own Access database using this code (which have worked fine for me earlier). SELECT * FROM MinHL IN...
4
by: GladGad | last post by:
I am not a real well versed query writer and therefore am having some problems figuring out how to write a parameter query where I want to input a partial name. I have tried a few different things,...
5
by: HowHow | last post by:
First time using crosstab query because tired of creating queries and put them together in one query (such a stupid thing to do :D). Not sure how it works still. I have link table called...
5
by: lisles | last post by:
i have a page funtion.php which hs the function to connect to the db /* Mysql Connection */ function connect(){ global $db_server,$db_user,$db_pass,$db;//Global Values from the config.php...
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
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...

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.