title: Only one expression can be specified in the select list when the subquery is not introduced with EXISTS nested case statements
body: <p>I am trying to create a query that gets the number of hours an event was open  below is my query. I am using case statements because it needs to take into account to only count weekdays. This is a step in the process my overall goal is to actually get the hours for those days. So for example if the the days is more than one count all those days and multiply by 8.. if its less than one do a datediff hours and just get the hours for that day.. Any help would be greatly appreciated!</p>
  
  <p>but I am getting the following error:</p>
  
  <p>Only one expression can be specified in the select list when the subquery is not introduced with EXISTS.</p>
  
  <pre><code>DECLARE @workdays int
  SELECT creationDateTime, 
         closedDateTime,DATEDIFF(dd, creationDateTime, closedDateTime)+1,
         CASE WHEN (DATEDIFF(dd, creationDateTime, closedDateTime)+1 &gt; 1)
              THEN (
                    SELECT creationDateTime ,closedDateTime, 
                      ((DATEDIFF(dd, creationDateTime, closedDateTime)+1)
                        -(DATEDIFF(wk, creationDateTime, closedDateTime) * 2)
                        -(CASE WHEN DATENAME(dw, creationDateTime)
                          = 'Sunday' THEN 1 ELSE 0 END)
                        -(CASE WHEN DATENAME(dw, closedDateTime) 
                          = 'Saturday' THEN 1 ELSE 0 END)
                    )*8 AS workdayhours
                    FROM table.ofevents where closedDateTime IS NOT NULL) END
  FROM table.ofevents where closedDateTime IS NOT NULL
  </code></pre>