If Access supported FULL OUTER jOIN, you could simply change LEFT to
FULL OUTER in the original query I gave you. However, since it
doesn't, you'll have to use a UNION:
select t.PN, l.[Rel Date] as lastweek, t.[Rel Date] as thisweek
from qThisWeek as t left join qLastWeek as l
on t.PN = l.PN and t.[Rel Date] =l.[Rel Date]
UNION
select t.PN, l.[Rel Date], t.[Rel Date]
from qThisWeek as t right join qLastWeek as l
on t.PN = l.PN and t.[Rel Date] =l.[Rel Date]
the second part is more important. when you say distinct records
what do you mean? group by? if so that does not work because if
there really are two dates the same, it will group them and show
only one. if it is something else, please explain.
No, I meant using the DISTINCT keyword, as in:
select DISTINCT PN,[Rel Date]
FROM table
WHERE Datepart("ww",Date())=Datepart("ww",[Ext Date])
If you use the UNION suggestion from above, you will not have to do
this part because using UNION without specifying ALL causes Jet to
discard duplicate records anyways.
If that doesn't do it for you, I will need to see sample source data
and desired results that illustrate the problem.- Hide quoted text -
this is from qlaste week
Material Rel Date
4G3450A02612K1R 3/26/2012
4G3450A02612K1R 4/3/2012
4G3450A02612K1R 4/11/2012
4G3450A02612K1R 4/17/2012
4G3450A02612K1R 4/24/2012
4G3450A02612K1R 5/1/2012
4G3450A02612K1R 5/23/2012
4G3450A02612K1R 6/5/2012
4G3450A02612K1R 6/5/2012
4G3450A02612K1R 7/3/2012
4G3450A02612K1R 7/3/2012
4G3450A02612K1R 7/11/2012
4G3450A02612K1R 7/23/2012
this is from qthisweek
Material Rel Date
4G3450A02612K1R 4/11/2012
4G3450A02612K1R 4/11/2012
4G3450A02612K1R 4/17/2012
4G3450A02612K1R 4/24/2012
4G3450A02612K1R 5/1/2012
4G3450A02612K1R 5/23/2012
4G3450A02612K1R 6/5/2012
4G3450A02612K1R 6/5/2012
4G3450A02612K1R 7/3/2012
4G3450A02612K1R 7/3/2012
4G3450A02612K1R 7/11/2012
4G3450A02612K1R 7/23/2012
4G3450A02612K1R 7/31/2012
this is the combine query. you see the 6/5 date is in there 4 times.
what it does is show each last week date with each this week date.
thuse 2 times 2. I only want to see it 2 times in the end result. not
4
Material lastweek thisweek
4G3450A02612K1R 4/11/2012 4/11/2012
4G3450A02612K1R 4/11/2012 4/11/2012
4G3450A02612K1R 4/17/2012 4/17/2012
4G3450A02612K1R 4/24/2012 4/24/2012
4G3450A02612K1R 5/1/2012 5/1/2012
4G3450A02612K1R 5/23/2012 5/23/2012
4G3450A02612K1R 6/5/2012 6/5/2012
4G3450A02612K1R 6/5/2012 6/5/2012
4G3450A02612K1R 6/5/2012 6/5/2012
4G3450A02612K1R 6/5/2012 6/5/2012
4G3450A02612K1R 7/3/2012 7/3/2012
4G3450A02612K1R 7/3/2012 7/3/2012
4G3450A02612K1R 7/3/2012 7/3/2012
4G3450A02612K1R 7/3/2012 7/3/2012
4G3450A02612K1R 7/11/2012 7/11/2012
4G3450A02612K1R 7/23/2012 7/23/2012
4G3450A02612K1R 7/31/2012
as far as the other, i will try the union query