title: Find the most recently updated rows according to a multi-column grouping
body: <p>I'm using SQL Server and T-SQL.</p>
  
  <p><strong>Sample Data:</strong></p>
  
  <p>I have data similar to the following readily consumable test data.</p>
  
  <pre><code>--===== Set the proper date format for the test data.
      SET DATEFORMAT dmy
  ;
  --===== Create and populate the Test Table
     DROP TABLE IF EXISTS #TestTable
  ;
   CREATE TABLE #TestTable
          (
           Item       VARCHAR(10) NOT NULL
          ,GroupA     TINYINT     NOT NULL
          ,GroupB     SMALLINT    NOT NULL
          ,Updated    DATE        NOT NULL
          ,Idx        INT         NOT NULL
          )
  ;
   INSERT INTO #TestTable WITH (TABLOCK)
          (Item,GroupA,GroupB,Updated,Idx)
   VALUES  ('ABC',7,2020,'14/11/2019',8)  --Return this row
          ,('ABC',7,2020,'10/11/2019',7)
          ,('ABC',6,2019,'14/11/2019',6)  --Return this row
          ,('ABC',5,2018,'13/11/2019',5)  --Return this row
          ,('ABC',5,2018,'12/11/2019',4)
          ,('ABC',7,2018,'14/11/2019',3)  --Return this row
          ,('ABC',7,2019,'25/11/2019',2)  --Return this row
          ,('ABC',7,2019,'18/11/2019',1)
  ;
  --===== Display the test data
   SELECT * FROM #TestTable
  ;
  </code></pre>
  
  <p><strong>Problem Description:</strong></p>
  
  <p>I need help in writing a query that will return the rows marked as "--Return this row". I know how to write a basic SELECT but have no idea how to pull this off.</p>
  
  <p>The basis of the problem is to return the latest updated row for each "group" of rows.  A "group" of rows is determined by the combination of the Item, GroupA, and GroupB columns and I need to return the full rows found.</p>