select sum("check") as ducplicateCheck
from (select nullif((select sum(forSum)
from checkDay), 0) /
nullif((select sum(forSum)
from checkDay), 0) as "check"
union all
select nullif((select sum(forSum)
from checkWeeks), 0) /
nullif((select sum(forSum)
from checkWeeks), 0)) as "check";

create view checkDateFormat as
select *
from (select * from user_setlist where bocco_user_id = 1) as us
where not exists(select *
from user_setlist
where us.start_date > '2022-08-31'
OR us.end_date < '2022-08-01'
OR us.user_setlist_number = 3);

create view checkDay as
(
select count(*) as forSum
from (select *
from checkDateFormat
where is_mon = true) as cdf
where cdf.is_mon = true
union all
select count(*)
from (select *
from checkDateFormat
where is_tue = true) as cdf
where cdf.is_tue = true
union all
select count(*)
from (select *
from checkDateFormat
where is_wed = true) as cdf
where cdf.is_wed = true
union all
select count(*)
from (select *
from checkDateFormat
where is_thu = true) as cdf
where cdf.is_thu = true
union all
select count(*)
from (select *
from checkDateFormat
where is_fri = true) as cdf
where cdf.is_fri = true
union all
select count(*)
from (select *
from checkDateFormat
where is_sat = true) as cdf
where cdf.is_sat = true
union all
select count(*)
from (select *
from checkDateFormat
where is_sun = true) as cdf
where cdf.is_sun = true);

create view checkWeeks as
select count(*) as forSum
from (select *
from checkDateFormat
where is_week1 = true) as cdf
where cdf.is_week1 = true
union all
select count(*)
from (select *
from checkDateFormat
where is_week2 = true) as cdf
where cdf.is_week2 = true
union all
select count(*)
from (select *
from checkDateFormat
where is_week3 = true) as cdf
where cdf.is_week3 = true
union all
select count(*)
from (select *
from checkDateFormat
where is_week4 = true) as cdf
where cdf.is_week4 = true
union all
select count(*)
from (select *
from checkDateFormat
where is_week5 = true) as cdf
where cdf.is_week5 = true;


돌려보니 일단 돌아감


근데 이거 쓴 사람 말고 이해 가능? 유지 보수 내다 버리란 소린데


아무리 생각해도 백엔드에서 하는 게 여러모로 보기 좋은데 후...sql싫다