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싫다
explain때려보고싶다 - dc Cpp
어우;; view 분리라도 하셈
네... 일단 돌아가게만 만듬
아까 설명으론 where절만 좀 길고 select랑 from은 한번으로 끝나는 쿼리가 나와야 정상인데
count로 따졌을 때 주 칼럼과 요일 칼럼을 각각 최대치를 1로 설정한 다음에 합쳐서 2 이상이면 겹침에러 처리를 해야함 대충 다 count로 때려넣는다고 되는 게 아니더라고
아까 설명이라는 단어 보고 글 검색해봤는데 테이블 개좆같이만들어놨네... 고생많구만 - dc Cpp
게다가 이거 조건1이라서 조건2도 비슷한 놈 하나 더 만들어야함. 백엔드에서 하면 코드 기껏해야 조건1, 2 합쳐서 30줄로 끝나는데 오늘도 직장의 불합리함을 느낍니다
직장 상사한테 코드 보여주면 님말이 맞음 할듯 ㄹㅇㅋㅋ
이대로 보여주면 반항하는줄 알거임 회사생활 잘 하려면 깔끔하게 정리해서 가라...대충 봐도 지금 길이에서 1/3정도로는 줄일 수 있겠구만
와씨발 백엔드는 절대 못하겠노
해당 케이스가 비정상인것뿐임 - dc Cpp