Server: Msg 512, Level 16, State 1, Line 1 Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.I understand what it is telling me, but I don't know how to fix it.
Select c.SpecDesc, isnull((select COUNT(ct.SpecDesc) FROM dbo.meetings m1 INNER JOIN coSpec ct ON m1.specid = ct.specid where (datepart(mm,m1.begintime)=1) and m1.specid=m.specid and datepart(yyyy,m1.begintime)=2002 and m1.iscompleted=1 and m1.iscancelled=0 and deptid = 1 or deptid = 23 GROUP BY ct.SpecDesc),0) as JAN, isnull((select COUNT(ct.SpecDesc) FROM dbo.meetings m1 INNER JOIN coSpec ct ON m1.specid = ct.specid where (datepart(mm,m1.begintime)=2) and m1.specid=m.specid and datepart(yyyy,m1.begintime)=2002 and m1.iscompleted=1 and m1.iscancelled=0 and deptid = 1 or deptid = 23 GROUP BY ct.SpecDesc),0) as FEB, isnull((select COUNT(ct.SpecDesc) FROM dbo.meetings m1 INNER JOIN coSpec ct ON m1.specid = ct.specid where (datepart(mm,m1.begintime)=3) and m1.specid=m.specid and datepart(yyyy,m1.begintime)=2002 and m1.iscompleted=1 and m1.iscancelled=0 and deptid = 1 or deptid = 23 GROUP BY ct.SpecDesc),0) as MAR, isnull((select COUNT(ct.SpecDesc) FROM dbo.meetings m1 INNER JOIN coSpec ct ON m1.specid = ct.specid where (datepart(mm,m1.begintime)=4) and m1.specid=m.specid and datepart(yyyy,m1.begintime)=2002 and m1.iscompleted=1 and m1.iscancelled=0 and deptid = 1 or deptid = 23 GROUP BY ct.SpecDesc),0) as APR, isnull((select COUNT(ct.SpecDesc) FROM dbo.meetings m1 INNER JOIN coSpec ct ON m1.specid = ct.specid where (datepart(mm,m1.begintime)=5) and m1.specid=m.specid and datepart(yyyy,m1.begintime)=2002 and m1.iscompleted=1 and m1.iscancelled=0 and deptid = 1 or deptid = 23 GROUP BY ct.SpecDesc),0) as MAY, isnull((select COUNT(ct.SpecDesc) FROM dbo.meetings m1 INNER JOIN coSpec ct ON m1.specid = ct.specid where (datepart(mm,m1.begintime)=6) and m1.specid=m.specid and datepart(yyyy,m1.begintime)=2002 and m1.iscompleted=1 and m1.iscancelled=0 and deptid = 1 or deptid = 23 GROUP BY ct.SpecDesc),0) as JUN, isnull((select COUNT(ct.SpecDesc) FROM dbo.meetings m1 INNER JOIN coSpec ct ON m1.specid = ct.specid where (datepart(mm,m1.begintime)=7) and m1.specid=m.specid and datepart(yyyy,m1.begintime)=2002 and m1.iscompleted=1 and m1.iscancelled=0 and deptid = 1 or deptid = 23 GROUP BY ct.SpecDesc),0) as JUL, isnull((select COUNT(ct.SpecDesc) FROM dbo.meetings m1 INNER JOIN coSpec ct ON m1.specid = ct.specid where (datepart(mm,m1.begintime)=8) and m1.specid=m.specid and datepart(yyyy,m1.begintime)=2002 and m1.iscompleted=1 and m1.iscancelled=0 and deptid = 1 or deptid = 23 GROUP BY ct.SpecDesc),0) as AUG, isnull((select COUNT(ct.SpecDesc) FROM dbo.meetings m1 INNER JOIN coSpec ct ON m1.specid = ct.specid where (datepart(mm,m1.begintime)=9) and m1.specid=m.specid and datepart(yyyy,m1.begintime)=2002 and m1.iscompleted=1 and m1.iscancelled=0 and deptid = 1 or deptid = 23 GROUP BY ct.SpecDesc),0) as SEP, isnull((select COUNT(ct.SpecDesc) FROM dbo.meetings m1 INNER JOIN coSpec ct ON m1.specid = ct.specid where (datepart(mm,m1.begintime)=10) and m1.specid=m.specid and datepart(yyyy,m1.begintime)=2002 and m1.iscompleted=1 and m1.iscancelled=0 and deptid = 1 or deptid = 23 GROUP BY ct.SpecDesc),0) as OCT, isnull((select COUNT(ct.SpecDesc) FROM dbo.meetings m1 INNER JOIN coSpec ct ON m1.specid = ct.specid where (datepart(mm,m1.begintime)=11) and m1.specid=m.specid and datepart(yyyy,m1.begintime)=2002 and m1.iscompleted=1 and m1.iscancelled=0 and deptid = 1 or deptid = 23 GROUP BY ct.SpecDesc),0) as NOV, isnull((select COUNT(ct.SpecDesc) FROM dbo.meetings m1 INNER JOIN coSpec ct ON m1.specid = ct.specid where (datepart(mm,m1.begintime)=12) and m1.specid=m.specid and datepart(yyyy,m1.begintime)=2002 and m1.iscompleted=1 and m1.iscancelled=0 and deptid = 1 or deptid = 23 GROUP BY ct.SpecDesc),0) as DEC FROM dbo.meetings m INNER JOIN coSpec c ON m.specid = c.specid where datepart(yyyy,m.begintime)=2002 and m.iscompleted=1 and deptid = 1 or deptid = 23 and m.iscancelled=0 and m.isblock=0 GROUP BY m.specid, c.SpecDescThanks in advance for any help.