
Untitled
By: a guest on
Apr 28th, 2012 | syntax:
None | size: 0.48 KB | hits: 13 | expires: Never
SQL Search Query ,how to assign weight to each input parameters and how to order the results by weight of input parameters,
select * from [Car]
where Make = @Make or
City = @City or
MinPrice >= @MinPrice or
MaxPrice <= @MaxPrice
order by
case when Make = @Make then 3 else 0 end +
case when City = @City then 2 else 0 end +
case when MinPrice >= @MinPrice then 1 else 0 end +
case when MaxPrice <= @MaxPrice then 1 else 0 end
desc