Advertisement
Guest User

Untitled

a guest
Jul 9th, 2015
257
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.36 KB | None | 0 0
  1. id | email | domain
  2. ---|--------------|--------
  3. 1 | foo@bar.de | bar.de
  4. 2 | baz@bar.de | bar.de
  5. 3 | admin@bar.de | bar.de
  6. 4 | info@bar.de | bar.de
  7. 5 | bar@foo.com | foo.com
  8. 6 | baz@foo.com | foo.com
  9.  
  10. select t.*
  11. from thetable t
  12. where (select count(*)
  13. from thetable t2
  14. where t2.domain = t.domain and t2.id <= t.id
  15. ) <= 2;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement