제가 짠 허접한 쿼리문인데요 ㅜ
select a.id, a.date, request, success
from
(select id, CONVERT(varchar(10),reservedt,126)as date, count(*)as request
from student
where convert(varchar(7),reservedt,126) = '2011-12' and id = 1111
group by id, CONVERT(varchar(10),reservedt,126))a
left outer join
(select id , convert(varchar(10),reservedt,126)as date, count(*)as success
from student
where key='6' and id=1111 and convert(varchar(7),reservedt,126 ) = '2011-12'
group by id, convert(varchar(10),reservedt,126 ))b
on a.date = b.date
order by a.date
1111 2011-12-02 3 NULL
1111 2011-12-07 3 NULL
1111 2011-12-08 6 NULL
1111 2011-12-14 5 2
결과값 입니다 제가 원하는 결과는 나옵니다 . 하지만 제가 궁금 한 것은 이방법이 과연 최선의 방법인가 입니다
쿼리문이 너무 길어 진거 같은데 조금 줄일수 있는 방법이 없을까요??