title: Sql - Grouping data
body: <p>Site Table</p>
  
  <p>WBSNumber | SiteCode | ASNumber | SiteName</p>
  
  <p>1..........................11112...........1.................SiteA</p>
  
  <p>1....................... .          11112 ..........    2...............       SiteA</p>
  
  <p>2.........................          42342..........     2...............       SiteB </p>
  
  <p>2.........................           42342..........      1...............         SiteB</p>
  
  <p>2.........................           42342..........      3...............         SiteB</p>
  
  <p>3.........................           78965..........      1...............         SiteC</p>
  
  <p>4.........................           78954..........      1...............        SiteD</p>
  
  <p>5.........................           112233..........     1...............        SiteE </p>
  
  <p>5.........................           112233..........     2...............        SiteE</p>
  
  <p>I'm struggling to write some sql that will return a list of all the sites, with a unique WBSNumber based on the highest ASNumber. </p>
  
  <p>So in my case, i'm expecting the following results back:</p>
  
  <p>WBSNumber | SiteCode | ASNumber | SiteName</p>
  
  <p>1....................... .          11112 ..........    2...............       SiteA</p>
  
  <p>2.........................           42342..........      3...............         SiteB</p>
  
  <p>3.........................           78965..........      1...............         SiteC</p>
  
  <p>4.........................           78954..........      1...............        SiteD</p>
  
  <p>5.........................           112233..........     2...............        SiteE</p>
  
  <p>Here WBSNumber is unique and only select the rows based on the highest ASNUmber.</p>