title: How to get just one output when a SELECT is in a loop?
body: <p>This is my code, at the end you can find the output. Basically there are 2 outputs. 
  So, how can I get just one output on this situation:</p>
  
  <h3>SQL</h3>
  
  <pre><code>DECLARE 
  @SubcategoriaId [nvarchar] (15),
  @Nombre [nvarchar](50),
  @Descripcion [nvarchar](100),
  @CantProd [numeric] (4,0)
  
  -- Declaring the cursor
  DECLARE XX_Cursor CURSOR
  FOR SELECT subcategoria.SubcategoriaId, subcategoria.Nombre, subcategoria.Descripcion
  FROM subcategoria 
  WHERE subcategoria.Categoria = 'Ca_2E006CC3'
  
  
  OPEN XX_Cursor
  
  -- I save the first cursor result into the variables @SubcategoriaId, @Nombre, @Descripcion
  FETCH NEXT FROM XX_Cursor INTO @SubcategoriaId, @Nombre, @Descripcion
  
  
  WHILE (@@FETCH_STATUS = 0)
  BEGIN
  
      SET @CantProd = (SELECT count(*) FROM TEST_COLUMN)
  
     -- with this select I will get a lot of rows but on a different requests because this is in a loop 
     Select @SubcategoriaId AS ID, @Nombre AS Name, @Descripcion AS Description, @CantProd AS Cant
  
     FETCH NEXT FROM XX_Cursor INTO @SubcategoriaId, @Nombre, @Descripcion
  END
  
  CLOSE XX_Cursor
  DEALLOCATE XX_Cursor
  </code></pre>
  
  <p></p>
  
  <h3>Output</h3>
  
  <p>This is the output:</p>
  
  <pre><code>ID          | Name                            | Description                     | Cant   
  Sc_7EAFEDED | Desc Subcategoria desde WEB 2.2 | Desc Subcategoria desde WEB 2.2 |  3
  
  ID          | Name                            | Description                     | Cant   
  Sc_7EAFEKMD | Desc Subcategoria desde WEB 1.1 | Desc Subcategoria desde WEB 1.1 |  1
  </code></pre>
  
  <p>But I need something like this:</p>
  
  <pre><code>ID          | Name                            | Description                     | Cant   
  Sc_7EAFEDED | Desc Subcategoria desde WEB 2.2 | Desc Subcategoria desde WEB 2.2 |  3 
  Sc_7EAFEKMD | Desc Subcategoria desde WEB 1.1 | Desc Subcategoria desde WEB 1.1 |  1
  </code></pre>