10-27-2019, 09:27 PM
|
#1
|
Newly Registered User
Join Date: Aug 2019
Posts: 86
Thanks: 106
Thanked 0 Times in 0 Posts
|
Two criteria
I have a query with 3 columns,
there are 5 types of filters , A,B,C,D,E
I want my query to show Total of only A,B and not Others.
But when I use OR criteria it is showing 2 rows (for each one of them).
How to get total in only one row for both ??
|
|
|
10-27-2019, 09:55 PM
|
#2
|
AWF VIP
Join Date: Jun 2011
Location: Ohio, USA
Posts: 5,386
Thanks: 22
Thanked 900 Times in 884 Posts
|
Re: Two criteria
Are you using a Groups and Total query? Hmm, would help if you post the SQL of the query.
__________________
Gina Whipp
Microsoft MVP (Access 2010-2015)
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
|
|
The Following User Says Thank You to GinaWhipp For This Useful Post:
|
|
10-27-2019, 09:57 PM
|
#3
|
AWF VIP
Join Date: Mar 2014
Location: The Great Land
Posts: 2,455
Thanks: 0
Thanked 573 Times in 569 Posts
|
Re: Two criteria
Show your query SQL. Maybe even some sample data.
__________________
Attach File Manager is below Advanced editor window, click Go Advanced below Quick Reply window. To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.
DEBUG! DEBUG! DEBUG! To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
|
|
The Following User Says Thank You to June7 For This Useful Post:
|
|
10-27-2019, 10:27 PM
|
#4
|
Newly Registered User
Join Date: Aug 2019
Posts: 86
Thanks: 106
Thanked 0 Times in 0 Posts
|
Re: Two criteria
Thank you for your reply .
Here is my SQL.
Code:
TRANSFORM Count([Instruments list].[MASTER List serial number]) AS [CountOfMASTER List serial number]
SELECT [Instruments list].[EQUIPMENT NAME], Count([Instruments list].[MASTER List serial number]) AS [Total Of MASTER List serial number]
FROM [Instruments list]
WHERE ((([Instruments list].[Instrument status2])="In-Use" Or ([Instruments list].[Instrument status2])="Spare"))
GROUP BY [Instruments list].[EQUIPMENT NAME], [Instruments list].[Instrument status2]
PIVOT [Instruments list].[Calibrating agency];
|
|
|
10-28-2019, 06:27 AM
|
#5
|
AWF VIP
Join Date: Jun 2011
Location: Ohio, USA
Posts: 5,386
Thanks: 22
Thanked 900 Times in 884 Posts
|
Re: Two criteria
Hmm, well it looks like Instrument Status2 might be preventing it from totaling on one line. What happens if you take that out of the GROUP BY? Oh and just noticed Calibrating Agency? Do those instruments use the same Agency?
__________________
Gina Whipp
Microsoft MVP (Access 2010-2015)
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
|
|
The Following User Says Thank You to GinaWhipp For This Useful Post:
|
|
10-28-2019, 07:50 AM
|
#6
|
Banishment Pending
Join Date: May 2011
Posts: 9,419
Thanks: 11
Thanked 2,285 Times in 2,237 Posts
|
Re: Two criteria
Come back 1 step. Do not make a cross-tab query yet, so run just this SQL:
Code:
SELECT [Instruments list].[EQUIPMENT NAME], Count([Instruments list].[MASTER List serial number]) AS [Total Of MASTER List serial number]
FROM [Instruments list]
WHERE ((([Instruments list].[Instrument status2])="In-Use" Or ([Instruments list].[Instrument status2])="Spare"))
GROUP BY [Instruments list].[EQUIPMENT NAME], [Instruments list].[Instrument status2]
That's going to produce the exact same data as the query you posted. It's going to have the "dupelicate" rows. Except, they aren't duplicate--they just seem that way to you.
Each row is going to be distinct--meaning some value in some field is different from every other row. You need to find what you call "duplicate" rows and determine which one you want to show up.
I suggest you run the SQL I posted and post back here some sample data to demonstrate what you are calling "duplicates".
|
|
|
The Following User Says Thank You to plog For This Useful Post:
|
|
11-02-2019, 12:07 AM
|
#7
|
Newly Registered User
Join Date: Aug 2019
Posts: 86
Thanks: 106
Thanked 0 Times in 0 Posts
|
Re: Two criteria
Dear sir ,
Thank you for your reply.
At first I made a query with exactly the SQL you gave to me , And the result were same as you described.
But I need Only one row for each equipment name, But Total should be from both "in-Use" and "spare".
Please tell me how to achieve this .
|
|
|
11-02-2019, 05:08 AM
|
#8
|
Banishment Pending
Join Date: May 2011
Posts: 9,419
Thanks: 11
Thanked 2,285 Times in 2,237 Posts
|
Re: Two criteria
If that's in response to my post, please do what I requested: Post back here sample data of what the queyr returned and tell me how it is incorrect.
|
|
|
The Following User Says Thank You to plog For This Useful Post:
|
|
11-02-2019, 09:58 AM
|
#9
|
AWF VIP
Join Date: Jun 2011
Location: Ohio, USA
Posts: 5,386
Thanks: 22
Thanked 900 Times in 884 Posts
|
Re: Two criteria
What happens if you remove the below from the Group By clause?
Code:
[Instruments list].[Instrument status2]
__________________
Gina Whipp
Microsoft MVP (Access 2010-2015)
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
|
|
The Following User Says Thank You to GinaWhipp For This Useful Post:
|
|
Thread Tools |
|
Display Modes |
Rate This Thread |
Linear Mode
|
|
All times are GMT -8. The time now is 07:47 PM.
|
|