I have one table that is supplied monthly to me. I did not build this table. IT has it built already and I am just querying from it. So I cannot chng the table layout. The table consists of the following information: year/month, site/skd, category, quantity, charge. I need to create a query that views what happened in a prior month, let's take jan2010 and see if anything changed in current month, let's take feb2010. They want information if a new site/skd, category was added and if so the charge. I have never done an unmatched query on 1 table. So I did it like this:
Make table:
Query1:
select [year/month], [site/skd], [category], sum([charge]) as sumofcharge
into Chrg1
from table
group by [year/month], [site/skd], [category]
having (([year/month])=[Enter State Date]);
Query2:
select [year/month], [site/skd], [category], sum([charge]) as sumofcharge
into Chrg2
from table
group by [year/month], [site/skd], [category]
having (([year/month])=[Enter End Date]);
Now I have two tables to run the unmatched to:
Query 3:
Select Chrg2.[year/month], Chrg2.[site/skd], Chrg2.category, Chrg2.sumofcharge
from Chrg2 left join Chrg1 on (Chrg2.cateogry = Chrg1.category) and (Chrg2.[site/skd] = Chrg1.[site/skd])
where (((Chrg1.[site/skd]) is null) and (Chrg1.category) is null))
order by Chrg2.[site/skd];
The reason I am posting is because this is a 3 step process and there are other tables they want the same thing done which are not affiliated with this table and I wanted to find something that might be a 1 query process so the queries are not so much. I did give explanations in the properties so they would understand the process I set up. I just thought there might be an all in one query that I could accomplish the same thing.
Thanks!!!!