Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Subtraction Problem In Where Clause

Author  Topic 

LacOniC
Starting Member

29 Posts

Posted - 2008-11-05 : 09:47:09
SELECT * FROM Table1 t1
JOIN Table2 t2 ON t1.Year= t2.Year
WHERE t1.Year in (t2.Year, t2.Year- 1)

Result only give me "WHERE t1.ID in (t2.Year)" section, "t2.Year - 1" doesn't work. What can be the problem?

bjoerns
Posting Yak Master

154 Posts

Posted - 2008-11-05 : 09:57:29
The join gives you only results where t1.Year = t2.Year already.
Go to Top of Page

LacOniC
Starting Member

29 Posts

Posted - 2008-11-05 : 10:01:15
I noticed it. Thank you.
Go to Top of Page
   

- Advertisement -