Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- create table test (
- company_id integer not null,
- client_id integer not null,
- client_status text
- );
- insert into test values
- -- company1
- (1, 1, 'y'),
- -- company2
- (2, 2, null),
- -- company3
- (3, 3, 'n'),
- -- company4
- (4, 4, 'y'),
- (4, 5, 'n'),
- -- company5
- (5, 6, null),
- (5, 7, 'n')
- ;
- 1
- 2
- 4
- 5
- select company_id,
- count(*) over (partition by company_id) as all_clients_count
- from test
- -- where all_clients_count != ... ?
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement