I want year in one table to be less or equal year in another table

I want year in one table to be less or equal year in another table

Post by Q2VjaWxpY » Thu, 22 Apr 2010 16:18:01


Hi

I have some problems writing a query and I hope someone can help me.

I have a database with serveal tables. In one table I have this information,
Lake ID-number, treatment, year for treatment. In another table I have Lake
ID-number, fish species (I am intrested in pike), year when pike is present.
I want to find all lakes that have pike present before the treatment was
done, I want the year in the second table to me less or equal the year in the
first table. Is there a easy way to do this?

Thanks
 
 
 

I want year in one table to be less or equal year in another table

Post by kc-mas » Thu, 22 Apr 2010 20:55:12

Try something like this substituting your table and field names.

SELECT tblTreatments.DateTreated, Year([DatePresent]) AS YearSpeciesPresent,
tblSpecies.Species
FROM tblTreatments INNER JOIN tblSpecies ON tblTreatments.LakeID =
tblSpecies.LakeID
WHERE (((Year([DatePresent]))<=Year([DateTreated])) AND
((tblSpecies.Species)="Pike"));

Regards

Kevin