Check out the Pastebin Gadgets Shop. We have thousands of fun, geeky & affordable gadgets on sale :-)Want more features on Pastebin? Sign Up, it's FREE!

Selecting the distinct values from three columns with the max of a fourth where there are duplicates

By: a guest on Feb 26th, 2012  |  syntax: None  |  size: 0.11 KB  |  views: 17  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print  |  QR code  |  clone
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. select max(n), a, b, c
  2. from mytable
  3. group by a, b, c
  5. select a, b, c, max(n)
  6. from table
  7. group by a, b, c;
clone this paste RAW Paste Data