Home Forums SQL Server 2008 SQL Server 2008 - General best optimized query for the requirement RE: best optimized query for the requirement
Andrew G
SSChampion
Points: 12809
More actions
March 20, 2013 at 1:55 am
#1598757
SELECT DISTINCT product_id
FROM fact_sales
WHERE (agent_id=1 AND product_code in (1))
OR (agent_id=2 AND product_code in (3))
OR (agent_id=3 AND product_code in (2))
OR (agent_id=4 AND product_code in (1))
AND & OR operators
http://www.w3schools.com/sql/sql_and_or.asp