开发者

can I combine these 2 simple queries into one query?

se开发者_JAVA百科lect count(distinct id) from svn where name='ant' and type='Bug'

and

select count(distinct id) from svn where name='ant' and type='Feature'

Is it possible to combine them into a single query that might reduce the execution time compared to running them individually?

Thanks for answering.


Yes, you can use group by:

SELECT type, count(distinct id) AS cnt
FROM svn
WHERE name = 'ant'
AND type IN ('Feature', 'Bug')
GROUP BY type
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜