title: Firebird WHERE clause in selecting fields
body: <p>I Have here firebird query and I dont think if this is correct.</p>
  
  <pre><code>SELECT 
        COUNT(STATUS) FROM(SELECT STATUS FROM T_TABLE2 WHERE STATUS = 'FAIL') AS FAIL,  
        DEVICENAME,  
        SITE_NUM,  
        COUNT(TEST_NUM)  
  FROM T_TABLE2 A  
  INNER JOIN T_TABLE1 B  
  ON A.TBL1_ID = B.ID  
  WHERE B.DEVICENAME = 'TANM1A009A_P28'  
  AND A.TEST_NUM = 'T810'  
  GROUP BY 
        DEVICENAME, 
        TESTER, 
        SITE_NUM 
  </code></pre>
  
  <p>I want to count the row of <strong>TEST_NUM</strong> even if it has FAIL value and I also want to count the <strong>STATUS</strong> that has FAIL value. 
  Thanks</p>