By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
create table mytable (
client varchar(20),
Monday varchar(1),
Tuesday varchar(1),
Wednesday varchar(1),
Thursday varchar(1),
Friday varchar(1),
Saturday varchar(1),
Sunday varchar(1),
);
insert into mytable values
('client 1', 'x', '', '', '', '', '', ''),
('client 2', '', '', 'x', '', '', '', 'x'),
('client 3', 'x', '', 'x', '', 'x', '', ''),
('client 4', 'x', '', 'x', '', '', '', ''),
('client 5', '', 'x', 'x', 'x', 'x', '', ''),
('client 6', '', 'x', 'x', 'x', 'x', '', '');
6 rows affected
select client
from mytable
group by client
having sum(case when Tuesday = 'x' then 1 else 0 end ) = 0
and sum(case when Thursday = 'x' then 1 else 0 end ) = 0
and sum(case when Saturday = 'x' then 1 else 0 end ) = 0
and sum(case when Sunday = 'x' then 1 else 0 end ) = 0
client |
---|
client 1 |
client 3 |
client 4 |
select *
from mytable
where Tuesday = ''
and Thursday = ''
and Saturday = ''
and Sunday = ''
client | Monday | Tuesday | Wednesday | Thursday | Friday | Saturday | Sunday |
---|---|---|---|---|---|---|---|
client 1 | x | ||||||
client 3 | x | x | x | ||||
client 4 | x | x |