Guest User

Untitled

a guest
Jan 7th, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. ID column1 column2
  2. -------------------------
  3. 1 test1 test1
  4. 2 test2 test2
  5. 3 test3 test3
  6.  
  7. ID column1 column2
  8. -------------------------
  9. 3 test1 test1
  10. 2 test2 test2
  11. 1 test3 test3
  12.  
  13. SELECT
  14. ROW_NUMBER() OVER (ORDER BY ID DESC) AS ID,
  15. column1,
  16. column2
  17. FROM dbo.Table1
  18. ORDER BY ID DESC
  19.  
  20. SELECT x.* FROM (
  21. SELECT TOP 7 t.*
  22. FROM dbo.Table1 t
  23. ORDER BY t.ID DESC
  24. ) x
  25. ORDER BY x.ID DESC
Add Comment
Please, Sign In to add comment