从其他查询mysql的结果生成结果

时间:2014-09-19 04:22:43

标签: php mysql sql

这是我的表

enter image description here

从上面

我的查询是

SELECT count_id, COUNT( questionID ) AS qid
FROM `sg_count`
GROUP BY count_id

它将获得输出enter image description here

我还想使用第一次查询的结果来计算(count_id)qid <5的人

1 个答案:

答案 0 :(得分:1)

试试这个 -

"SELECT count(qid) FROM (
    SELECT count_id, COUNT( questionID ) AS qid FROM `sg_count` GROUP BY count_id
) as count_data where qid < 5" ;