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

Add criteria from counting more than 2 field

yosiro
34
Am sory if the title is not matching with this question.

I have 2 table and 1 query, like this picture below:



The query said:

Expand|Select|Wrap|Line Numbers
  1. SELECT A1, (SELECT COUNT(C1) FROM Table1 WHERE Table2.ID=Table1.C1 OR Table2.ID=Table1.C2) AS Total
  2. FROM Table2;
  3.  
And i want to show the result of query just in year 2016, how to code this query?

Am sory for my bad english, i hope you understand. Thank you
Mar 3 '16 #1

✓ answered by NeoPa

You'd probably want something like :
Expand|Select|Wrap|Line Numbers
  1. SELECT [A1]
  2.      , (SELECT Count(*)
  3.         FROM   [Table1]
  4.         WHERE  (Year([Dt])=2016)
  5.           AND  ([Table2].[ID]=[Table1].[C1] OR [Table2].[ID]=[Table1].[C2])) AS [Total]
  6. FROM   [Table2]

3 956
NeoPa
32,556 Expert Mod 16PB
You'd probably want something like :
Expand|Select|Wrap|Line Numbers
  1. SELECT [A1]
  2.      , (SELECT Count(*)
  3.         FROM   [Table1]
  4.         WHERE  (Year([Dt])=2016)
  5.           AND  ([Table2].[ID]=[Table1].[C1] OR [Table2].[ID]=[Table1].[C2])) AS [Total]
  6. FROM   [Table2]
Mar 3 '16 #2
yosiro
34
It works, but i want to add 1 column in the query, presented the year after the Total column
Mar 3 '16 #3
NeoPa
32,556 Expert Mod 16PB
That's a shame. It's a completely different question from the one this thread is about and would require a whole different approach. Really unfortunate that you didn't include the whole question at the start.

You'll need to post a new question for that one.
Mar 4 '16 #4

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

Similar topics

1
by: Sue | last post by:
What do I put as criteria in a date field to return all records where the date field is blank? Thanks for all help!! Sue
2
by: ChasW | last post by:
I just read these 2 pages. These are most helpful, but leave me with a question. http://www.mvps.org/access/queries/qry0005.htm http://www.mvps.org/access/forms/frm0007.htm I have a Multi...
6
by: pobnospam | last post by:
I have a field called ingredients where multiple ingredients can be contained in one record (client request). Now when a report is run I need to prompt a user to determine which records to display...
5
by: AdminSparky | last post by:
Greetings, I am searching a field that contains one or more instances of a 3-letter "error" code. I am using a WHERE clause similar to: ((tblName.fldName) Like . & "*") The above returns...
16
by: tiarynn | last post by:
Hi everyone, I am a beginning to intermediate user with Access 2000 on XP. I am trying to create a query from a table of more than 1300 records. I need to look up individuals by their SSN only...
2
by: dympna | last post by:
Hi can anyone suggest a fix for this... as I am a novice in access. I have created a training table with the following fields Employee Name - joe Training Received - Fork lift Date Received...
8
by: John Torres | last post by:
I have created a report base on a query. And on Query or report I want to remove all entry with “Set-Up Charge” under Comment field (Memo). I tried < >”Set-Up Charge” but it shows all the...
4
by: Jonathan | last post by:
I have a SQL stored procedure for adding a new record in a transactions table. It also has two return values: CounterID and IDKey. I want to create a webservice that accepts the 10 input...
1
by: accessbeginerry | last post by:
Hello, i am starting to give up :( search the forum and tried to correct my mistakes - but no luck. Does anyone have a clue what i am doing wrong? I have a form and subform. I have a button...
5
by: Pierkes | last post by:
Hi, Iám having problems with a criteria in a query. The field is a yes/no field. I have a yes/no field on a form which i can check of uncheck. The field is called . In the query criteria i...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.