Advertisement
Guest User

Untitled

a guest
May 31st, 2016
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. create table test (
  2. company_id integer not null,
  3. client_id integer not null,
  4. client_status text
  5. );
  6.  
  7.  
  8. insert into test values
  9. -- company1
  10. (1, 1, 'y'),
  11.  
  12. -- company2
  13. (2, 2, null),
  14.  
  15. -- company3
  16. (3, 3, 'n'),
  17.  
  18. -- company4
  19. (4, 4, 'y'),
  20. (4, 5, 'n'),
  21.  
  22. -- company5
  23. (5, 6, null),
  24. (5, 7, 'n')
  25. ;
  26.  
  27. 1
  28. 2
  29. 4
  30. 5
  31.  
  32. select company_id,
  33. count(*) over (partition by company_id) as all_clients_count
  34. from test
  35. -- where all_clients_count != ... ?
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement