title: How to write a query to fetch all the details of user along with the risk analysis
body: <p>Before HackerLife Insurance isses a policy, they determine a risk category for each applicants. The category is based on the outcome of various medical tests , i.e. KFT,LFT, and CBC.East result is a value of 1 to 10</p>
  <p>If the sum of test score is: Greater than 20 then risk is 'Low' Between 16 and 20, inclusive then the risk is 'Medium' Lower than 16 then the risk is 'High'</p>
  <p>Write a query to fetch all the details of user along with the risk analysis in the format specified in the sample output. The customer are user_id, insurance_type, KFT score, LFT score, CBC score, risk category</p>
  <p>Note: Order the result by the type of insurance, then risk category, user id</p>
  <p>Schema: users table</p>
  <pre><code>user_id --- int --- unique id of the user
  insuarance type --- varchar(15) --- type of insurance the user opted for
  </code></pre>
  <p>tests table:</p>
  <pre><code>user_id --- int ---id of the user referring to users table
  test_type --- char(3) --- type of the test done for the user
  test_score --- int ---score of the test
  </code></pre>
  <p>Expected output:</p>
  <pre><code>user_id insurance_type kft lft cbc  risk
    5109   Endowment      4   5   10  medium
    5324   Health         5   9   8   low
    9762   Whole life     4   7   3   High
    1071   Whole life     10  4   4   Medium
    5419   Whole life      6  6   8   Medium 
  </code></pre>
  <p>Query I am using:</p>
  <pre><code>select U.user_id, u.insurance_type, 
  case
  when T.test_type = ‘KFT’  then KFT,
  case
  when T.test_type = ‘LFT’ then LFT,
  case
  when T.test_type = ‘CBC’ then CBC,
  from users U 
  inner join tests T on U.user_id = T.user_id
  </code></pre>