title: SQL query for highest netpay among the employees
body: <p>SQL query to display employees records whose netpay is greater than any other employee. Display name,salary,commission,netpay and manager name.
  Exclude if manager name is null.
  Netpay=salary+commission.</p>
  <p>Table:</p>
  <ul>
  <li><code>employees</code> -- commission, dep_id, emp_id, emp_name, hire_date, job_name, manager_id, salary</li>
  </ul>
  <p>This is my query:</p>
  <pre><code>SELECT e.emp_name, e.salary, e.commission, (e.salary+e.commission) AS netpay, x.emp_name
  FROM employees e
  INNER JOIN employees x ON x.emp_id = e.manager_id
  WHERE (e.salary+e.commission) = (SELECT MAX(salary+commission) FROM employees where manager_id IS NOT NULL);
  </code></pre>
  <p>I'm not getting the test cases cleared for the above query. can any one help me out to solve this.</p>
  <p><a href="https://i.stack.imgur.com/VWmm6.png" rel="nofollow noreferrer">employee table</a></p>
  <p>The output I'm getting is</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>emp_name</th>
  <th>salary</th>
  <th>commission</th>
  <th>netpay</th>
  <th>manager</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>Tucker</td>
  <td>1600</td>
  <td>7000</td>
  <td>8600</td>
  <td>blaze</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>I think this the max value among the records but still i have no idea whats the problem with this getting solved.</p>
  <p>I am adding the create table and some insert commands:</p>
  <pre><code>CREATE TABLE employees(emp_id number, emp_name varchar2(25), job_name varchar2(25), manager_id number, hire_date date, salary number, commission number, dep_id number) ;
  
  INSERT INTO employees VALUES(68319,'kayling', 'president', null, 11/18/1991,6000,3100,1001); 
  INSERT INTO employees VALUES(66928,'blaze', 'manager', 68319,5/1/1991,2750,3200,3001); 
  INSERT INTO employees VALUES(68454,'tucker', 'salesman', 66928,9/8/1991,1600,7000,3001); 
  INSERT INTO employees VALUES(65646,'clare', 'manager', 68319, 5/9/1991,2550,2300,1001); 
  INSERT INTO employees VALUES(67858,'scarlet', 'analyst', 65646, 1/11/1991,3100,520,2001); 
  </code></pre>