SELECT COUNT中的SELECT COUNT

时间:2016-03-14 08:35:04

标签: mysql

我正在尝试此代码。

SELECT COUNT(SELECT COUNT(postnID) AS Total,
 postnID, Unit_DBM, job_type, 
 level, internal_plantilla, INCID,
 ITEM_NO_2005, position_type, 
 position_status 
 FROM plantilla 
 GROUP BY internal_plantilla, level, INCID, postnID, position_status       
 ORDER BY internal_plantilla, postnID) as num 
 FROM plantilla

但是在mysql中有错误。如何在选择计数内执行选择计数?

1 个答案:

答案 0 :(得分:0)

你可以做:

SELECT COUNT(*) from (SELECT COUNT(postnID) AS Total,
 postnID, Unit_DBM, job_type, 
 level, internal_plantilla, INCID,
 ITEM_NO_2005, position_type, 
 position_status 
 FROM plantilla 
 GROUP BY internal_plantilla, level, INCID, postnID, position_status       
 ORDER BY internal_plantilla, postnID) as num