选择字段时的Firebird WHERE子句

时间:2013-10-18 00:53:38

标签: select firebird where-clause

我这里有firebird查询,我不认为这是否正确。

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 

我想计算 TEST_NUM 的行,即使它有FAIL值,我也想计算具有FAIL值的 STATUS 。 感谢

1 个答案:

答案 0 :(得分:0)

我真的不知道FireBird但是从MSSQL的角度来看你为什么不尝试这个?

SELECT 
      COUNT(A.STATUS) as 'FAIL', 
      B.DEVICENAME, 
      (TableofYourSitenum)SITE_NUM, -- i do no know what table this from 
      (TableofYourTestnum)COUNT(TEST_NUM)  as 'TESTNUM COUNT' --and this also you need to put the table name,
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 
      A.STATUS, 
      (TableofYourTestnum)TESTNUM