Both of these queries return the results you expect for the sample data provided.
SELECT
*
FROM
dbo.Temp_Models AS M INNER JOIN
dbo.Temp_Attributes AS MA
ON MA.ModelId = M.ModelID
WHERE
-- either of thes will work, I prefer in
MA.AttributeID IN (7, 29)
/*
(
MA.attributeID = 29 OR
MA.attributeId = 7
)
*/
AND
(
MA.Value LIKE '%IL%' OR
MA.Value >= 0.03860 AND MA.Value = 0.0360 AND
CONVERT(DECIMAL(10, 5), MA.Value) <= 0.0840
)
) AND
(M.ProductID = 2)
You may want to check out this article on Dynamic Search Conditions
Jack Corbett
Consultant - Straight Path Solutions
Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question