Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
I have the select query with where condition has Or clause does fiscal_year and R_status apply to Or clause account condition.or should i use again fiscal year and r_status with or clause condtion at the bottom. WHERE FISCAL_YEAR = 2014 AND ACCOUNT BETWEEN 8000 AND 8999 and R_STATUS in(1,9) or ACCOUNT BETWEEN 3000 AND 3500 Thanks a lot for the helpful info.
Ifor
Aged Yak Warrior
700 Posts
Posted - 2015-01-26 : 13:09:49
What you have amounts to:
WHERE( FISCAL_YEAR = 2014 AND R_STATUS IN (1, 9) AND ACCOUNT BETWEEN 8000 AND 8999) OR ACCOUNT BETWEEN 3000 AND 3500;
I suspect you want:
WHERE FISCAL_YEAR = 2014 AND R_STATUS IN (1, 9) AND ( ACCOUNT BETWEEN 8000 AND 8999 OR ACCOUNT BETWEEN 3000 AND 3500 );