Query for single column based on ID and fkID (1 Viewer)

TB11

Member
Local time
Today, 13:24
Joined
Jul 7, 2020
Messages
78
Hi. I have 2 tables.
Table1 IDProject, ProjectDate (this table has only 1 date per IDProject)
Table 2 IDProjectGroup, fkProject, GroupDate (this table has 1 or multiple dates, all relating to the IDProject from table 1, but the date in table 2 is not a duplicate of date from table 1)

Wish list for query: I would like to have one column for a totals query, that shows both the ProjectDate from table 1 and the GroupDate from table 2. I need this single column for count, min and max in the totals query.

I can't seem to get the single column needed. I've tried different inner joins, no joins, separate queries, etc.

Is this something I can do with a query or do I need to restructure table 1?
 

theDBguy

I’m here to help
Staff member
Local time
Today, 11:24
Joined
Oct 29, 2018
Messages
21,358
Perhaps showing some sample data might help understand what you want?
 

plog

Banishment Pending
Local time
Today, 13:24
Joined
May 11, 2011
Messages
11,611
If you need to evaluate the values together, then they should probably be in the same table. I think 1 paragraph without any database jargon in it that explains what this data represents would be helpful as well as 2 sets of sample data:

A. STarting data from your tables. Include table and field names and enough data to cover all cases.

B. Expected results of A. Show us what data you expect to end up with when you feed in the data from A above.

Again, 2 sets of data--starting and expected results.
 

TB11

Member
Local time
Today, 13:24
Joined
Jul 7, 2020
Messages
78
Sorry about that. Sample data:
Table1
IDProject , ProjectDate
22 , 7/30/2021
25, 8/1/2021
28, 8/2/20211

Table 2
IDProjectGroup, fkProject, GroupDate
15 , 22, 7/31/2021
16, 22, 8/1/2021
17, 22, 8/2/2021
18 , 25 , 8/2/2021
19 , 28, 8/3/2021
20, 28 , 8/4/2021
21, 28 , 8/7/2021

Wish list:
IDProject, AllDates
22 , 7/30/2021 (from table 1)
22, 7/31/2021 (from table 2)
22, 8/1/2021 (from table 2)
22, 8/2/2021 (from table 2)
25, 8/1/2021 (from table 1)
25, 8/2/2021 (from table 2)
28, 8/2/2021 (from table 1)
28, 8/3/2021 (from table 2)
28, 8/4/2021 (from table 2)
28, 8/7/2021 (from table 2)
 

theDBguy

I’m here to help
Staff member
Local time
Today, 11:24
Joined
Oct 29, 2018
Messages
21,358
Ah, looks like you just need a UNION query.
 

Users who are viewing this thread

Top Bottom