title: How can I write this MSSQL database query?
body: <p>I have a specific scenario in which I have to assign discounts applicable on some Car Leads based on some given rules of Permutation and Combination.</p>
  
  <p>To explain in details, I have these two tables:</p>
  
  <p><a href="https://i.stack.imgur.com/RuptY.png" rel="nofollow noreferrer">Below table contains some raw data of all leads of vehicle</a></p>
  
  <p>And:</p>
  
  <p><a href="https://i.stack.imgur.com/LRz2T.png" rel="nofollow noreferrer">Below Table contains the Rules (Permutation and combination) for all discounts</a></p>
  
  <p>What I want is to get the best rule from Rules based on the maximum number of variables matches in Rules from Lead.</p>
  
  <p>How can I write the SQL for this?</p>