// description of your code here
select
convert(varchar(6),n.notedate) as [date],count(*) as cnt
into
from
orders o inner join
orderdetail od on o.orderid = od.orderid inner join
ordernotes n on o.orderid = n.orderid
where
od.jurisdictionid = 3152 and
od.serviceid in (3,4,12,13,15,18) and
(n.noteid = 18 and n.notedate between '1/1/2006 12:01 AM' and '12/31/2006 11:59 PM')
--(n.noteid = 129 and n.notedate between '1/1/2006 12:01 AM' and '12/31/2006 11:59 PM')
group by
convert(varchar(6),n.notedate)
order by
convert(varchar(6),n.notedate)
select * from
compute sum(cnt)
drop table