SHARE
TWEET

Untitled

a guest Oct 12th, 2017 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. +----+-----------+
  2. | id | name      |
  3. +----+-----------+
  4. |  1 | error1    |
  5. |  2 | error2    |      
  6. |  3 | error3    |      
  7. |  4 | error2    |      
  8. |  5 | error3    |
  9. +----+-----------+
  10.    
  11. +----+-----------+
  12. | id | name      |
  13. +----+-----------+
  14. |  1 | error1    |            
  15. |  4 | error2    |      
  16. |  5 | error3    |
  17. +----+-----------+
  18.    
  19. from sqlalchemy import func
  20. db.session.query(func.max(example.id),example.name).group_by(example.name).all()
RAW Paste Data
Top