0

我在这里有火鸟查询,我认为这是否正确。

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。谢谢

4

1 回答 1

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 
于 2013-10-18T01:11:41.410 回答