Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. INSERT INTO MYTABLE_TEST VALUES (
  2. 'USER1',
  3. '11'
  4. );
  5.  
  6. INSERT INTO MYTABLE_TEST VALUES (
  7. 'USER2',
  8. '21'
  9. );
  10.  
  11. INSERT INTO MYTABLE_TEST VALUES (
  12. 'USER2',
  13. '22'
  14. );
  15.  
  16. INSERT INTO MYTABLE_TEST VALUES (
  17. 'USER3',
  18. '31'
  19. );
  20.  
  21. INSERT INTO MYTABLE_TEST VALUES (
  22. 'USER3',
  23. '32'
  24. );
  25.  
  26. INSERT INTO MYTABLE_TEST VALUES (
  27. 'USER3',
  28. '33'
  29. );
  30.  
  31. SELECT * FROM MYTABLE_TEST;
  32.  
  33. SELECT
  34. NAME,
  35. VAL
  36. FROM
  37. (
  38. SELECT
  39. NAME,
  40. VAL,
  41. ROW_NUMBER() OVER(
  42. PARTITION BY NAME
  43. ORDER BY
  44. VAL DESC NULLS LAST
  45. ) RN
  46. FROM
  47. MYTABLE_TEST T
  48. )
  49. WHERE
  50. RN = 1;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement