Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 28th, 2012  |  syntax: None  |  size: 0.48 KB  |  hits: 13  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. SQL Search Query ,how to assign weight to each input parameters and how to order the results by weight of input parameters,
  2. select * from [Car]
  3. where Make = @Make or
  4.       City = @City or
  5.       MinPrice >= @MinPrice or
  6.       MaxPrice <= @MaxPrice
  7. order by
  8.       case when Make = @Make then 3 else 0 end +
  9.       case when City = @City  then 2 else 0 end +
  10.       case when MinPrice >= @MinPrice then 1 else 0 end +
  11.       case when MaxPrice <= @MaxPrice then 1 else 0 end
  12.       desc