theresakad
Programmer
I am having trouble structuring my query to just pull the data I want instead of all the records. I could really use your help.
I have a table that holds schedules for all of our customers. Each schedule is related to an agreement. There could be multiple schedules per agreement for one customer. I want to know, for a particular year, the earliest schedule date and the latest agreement date that was signed before the earliest schedule date occurred. I sure hope that makes sense to everyone.
I need to show other columns from both the a and b tables but when I do, then I get all records relating to the customer, not just the data i want.
--sample logic
select a.customer, min(a.startDate), max(b.signDate)
from a INNER JOIN b ON a.ID = b.ID
where a.year = 2011
group by a.startDate, b.signDate
having max(b.signDate)< min(a.startdate)
Your help is greatly appreciated.
thank you
I have a table that holds schedules for all of our customers. Each schedule is related to an agreement. There could be multiple schedules per agreement for one customer. I want to know, for a particular year, the earliest schedule date and the latest agreement date that was signed before the earliest schedule date occurred. I sure hope that makes sense to everyone.
I need to show other columns from both the a and b tables but when I do, then I get all records relating to the customer, not just the data i want.
--sample logic
select a.customer, min(a.startDate), max(b.signDate)
from a INNER JOIN b ON a.ID = b.ID
where a.year = 2011
group by a.startDate, b.signDate
having max(b.signDate)< min(a.startdate)
Your help is greatly appreciated.
thank you