title: An aggregate may not appear in the WHERE clause unless it is in a subquery
body: <p>I am trying to use below query to sort out the consumer list based on 
  1)actual count and then 
  2)subcount based on values as in Sla_state =1 and result =0 ..</p>
  
  <p><strong>Query ..</strong></p>
  
  <p>select  consumer as "Consumer", class_name as "Service", count(consumer) as "totalcount", avg(responsetime) as "AvgResponseTime (ms)", max(responsetime) as "Max ResponseTime (ms)" , sla_state as "sla", result  as "result_state" , count(1) as "subcount"<br>
  from
   DPOWER.business_transaction bt join DPOWER.mmfg_business_transaction mbt on 
  (bt.business_trans_id = mbt.business_trans_id) join DPOWER.transaction_class tc on (bt.class_id = tc.class_id) and sla_state = 1 and result=0 
  where<br>
   (bt.starttime >= '20150701000000000000' and bt.endtime &lt;= '20150801000000000000')  group by  consumer, sla_state, result, class_name order by  consumer</p>
  
  <p>The above query worked ..but I am able to get only the subcount and not the total count of the consumers. Below is the three table structures.  Can anyone figure out how to get the total count .( i tried all possible way like count (*) etc but that didnt work out..also if I use aliases I get "multipart idenfier not bound" error.</p>