title: How to obtain Multiple subtotals using SQL and VBS from Access Table?
body: <p>I am trying to obtain multiple subtotals from an Access Table , using a external vbs file vbscript in Windows. </p>
  
  <pre><code>mySQL = "SELECT [Data.Time],"&amp; Quantity &amp;"*Sum([Data.Price]) AS 
  SumOfPrice FROM Data WHERE (  ( [Data.Ticker] Like '"&amp; CE1 &amp;"'  
  Or [Data.Ticker] Like '"&amp; CE2 &amp;"' Or [Data.Ticker] Like '"&amp; CE3 &amp;"' 
  Or [Data.Ticker] Like '"&amp; CE4 &amp;"' Or [Data.Ticker] Like '"&amp; CE5 &amp;"' 
  Or [Data.Ticker] Like '"&amp; PE1 &amp;"' Or [Data.Ticker] Like '"&amp; PE2 &amp;"' 
  Or [Data.Ticker] Like '"&amp; PE3 &amp;"' Or [Data.Ticker] Like '"&amp; PE4 &amp;"' 
  Or [Data.Ticker] Like '"&amp; PE5 &amp;"' 
   ) AND ([Data.DateTr]=#"&amp; DateIn &amp;"#))
   GROUP BY [Data.Time] HAVING [Data.Time] &gt; #"&amp; startTime(i) &amp;"# and (((Count([Data.Ticker]))= 10))"
  </code></pre>
  
  <p>Further Processing....</p>
  
  <pre><code>objRecordSet2.Open mySQL,objConnection, adOpenStatic, adLockOptimistic
  objRecordSet2.MoveFirst     
  Do Until objRecordSet2.EOF
      If objRecordSet2.Fields.Item(1) &gt; testvalue
  </code></pre>
  
  <p>Presently it provides the total of CE+PE for each time (every 1 minute)
  Must ensure exactly 5 CE records and 5 PE records for every time instant , hence total 10.</p>
  
  <p>Can we Modify it to provide totals of CE and PE seperately.
  SELECT Time , SumofCEPrice , SumofPEPrice for each 1 minute</p>