title: What is wrong in this sql select statement?
body: <p>Here is my select statement,</p>
  
  <pre><code>SELECT TOP 1
    EmpId, RemainingAdvance 
  FROM SalaryDetails
  WHERE EmpId IN (SELECT Emp_Id
                  FROM Employee
                  WHERE Desig_Id='27')
  ORDER BY CreatedDate DESC
  </code></pre>
  
  <p>When i executed <code>SELECT Emp_Id FROM Employee WHERE Desig_Id='27'</code> the results were</p>
  
  <blockquote>
    <p>Emp_Id<br/>   16<br/>   17</p>
  </blockquote>
  
  <p>But when i execute my first statement it gives me result for only <code>16</code> but no output <code>17</code>...
  I have records for both EmpId's in <code>SalaryDetails</code> Table.....</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>Removing TOP 1 from my query i got this,</p>
  
  <pre><code>SELECT EmpId, RemainingAdvance FROM SalaryDetails 
  where EmpId in (select Emp_Id from Employee where Desig_Id='27')
                 ORDER BY CreatedDate DESC 
  </code></pre>
  
  <p>gave me</p>
  
  <p><a href="https://i.stack.imgur.com/DSjhR.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/DSjhR.jpg" alt="alt text"></a></p>
  
  <p>I want results for <code>EmpId 16,17</code> <code>ORDER BY CreatedDate DESC</code>... Because my now my <code>Desig_Id='27'</code> and i will change it with a variable <code>@CategoryId</code> ... So there may be 'n' number of employees based on <code>@CategoryId</code></p>
  
  <pre><code>EmpId  RemainingAdvance
  16                354.00
  17                 0.00
  </code></pre>