title: SELECT TOP 10 rows
body: <p>I have built an SQL Query that returns me the top 10 customers which have the highest outstanding. The oustanding is on product level (each product has its own outstanding).</p>
  
  <p><a href="https://i.stack.imgur.com/MiuAH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/MiuAH.png" alt="enter image description here"></a></p>
  
  <p>Untill now everything works fine, my only problem is that if a certain customer has more then 1 product then the second product or more should be categorized under the same customer_id like in the second picture (because the first product that has the highest outstanding contagions the second product that may have a lower outstanding that the other 9 clients of top 10).
  How can I modify my query in order to do that? Is it possible in SQL Server 2012?</p>
  
  <p><a href="https://i.stack.imgur.com/oA3pC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/oA3pC.png" alt="enter image description here"></a></p>
  
  <p>My query is:</p>
  
  <pre><code>select top 10 CUSTOMER_ID
               ,S90T01_GROSS_EXPOSURE_THSD_EUR
               ,S90T01_COGNOS_PROD_NAME
               ,S90T01_DPD_C
               ,PREVIOUS_BUCKET_DPD_REP
               ,S90T01_BUCKET_DPD_REP
  from [dbo].[DM_07MONTHLY_DATA]
  where S90T01_CLIENT_SEGMENT = 'PI'
        and YYYY_MM = '2017_01'
  group by CUSTOMER_ID
          ,S90T01_GROSS_EXPOSURE_THSD_EUR
          ,S90T01_COGNOS_PROD_NAME
          ,S90T01_DPD_C
          ,PREVIOUS_BUCKET_DPD_REP
          ,S90T01_BUCKET_DPD_REP
  order by S90T01_GROSS_EXPOSURE_THSD_EUR desc;
  </code></pre>