title: SQL: I am getting only one row as output where I should be getting 4. What's wrong with my code
body: <p>This is the code that I am using</p>
  
  <pre><code>CREATE PROCEDURE Sp_bonus @bonus      INT, 
                            @lastname   VARCHAR(50) out, 
                            @firstname  VARCHAR(50) out, 
                            @dateofhire DATE out, 
                            @salary     SMALLMONEY out, 
                            @bonusmoney SMALLMONEY out 
  AS 
      IF @bonus = 20 
        BEGIN 
            SELECT @lastname = lastname, 
                   @firstname = firstname, 
                   @dateofhire = dateofhire, 
                   @salary = salary, 
                   @bonusmoney = ( salary * ( @bonus ) * 0.01 ) 
            FROM   salesreps 
            WHERE  dateofhire &lt; '12/31/2000' 
        END 
  
      IF @bonus = 5 
        BEGIN 
            SELECT @lastname = lastname, 
                   @firstname = firstname, 
                   @dateofhire = dateofhire, 
                   @salary = salary, 
                   @bonusmoney = ( salary * ( @bonus ) * 0.01 ) 
            FROM   salesreps 
            WHERE  dateofhire &gt;= '12/31/2000' 
        END 
  
      DECLARE @lastname   VARCHAR(50), 
              @firstname  VARCHAR(50), 
              @dateofhire DATE, 
              @salary     SMALLMONEY, 
              @bonusmoney SMALLMONEY 
  
      EXEC Sp_bonus 
        @bonus=20, 
        @lastname=@lastname out, 
        @firstname=@firstname out, 
        @dateofhire=@dateofhire out, 
        @salary=@salary out, 
        @bonusmoney=@bonusmoney out 
  
      SELECT lastname=@lastname, 
             firstname=@firstname, 
             dateofhire=@dateofhire, 
             salary=@salary, 
             bonus=@bonusmoney 
  </code></pre>
  
  <p>The result of this is </p>
  
  <pre><code> Lastname   Firstname  Dateofhire   Salary      Bonus
   Bernstein  Michael    1991-05-25   98000.00    19600.00 
  </code></pre>
  
  <p>While there are 3 more records which should be here. I don't understand what I am doing wrong in the code that it is only giving me one output line. I checked the logic for where, which is correct, and also the calculation for bonus is coming out as correct. </p>
  
  <p>The only problem is that it shows me only one line of output, whether I use bonus=20 or bonus=5</p>
  
  <p>Any suggestions.</p>