当前位置: 动力学知识库 > 问答 > 编程问答 >

sql - Select and count inside a select in mysql

问题描述:

This question already has an answer here:

  • Does Mysql have an equivalent to @@ROWCOUNT like in mssql?

    3 answers

网友答案:

Try this..it provide number of total record.

Select count(word_id) from (SELECT `word_id`, SUM(`is_core`) as `cores` 
FROM `table` GROUP BY `word_id` ORDER BY  `cores` DESC having SUM(`is_core`) > 1)
网友答案:

Why do you use nested queries? You can have same result with a single query.

SELECT `word_id`, SUM(`is_core`) as `cores` 
FROM `table` 
GROUP BY `word_id` DESC 
HAVING `cores` > 1 
ORDER BY  `cores`;
分享给朋友:
您可能感兴趣的文章:
随机阅读: