开发者

count query filter

I want to filter counted query result.

select count(d开发者_Go百科istinct tmr_id) AS Count ,CONTRACTID from status_handling 

This query return 2 columns like:

Count ContractID

1    23344
2    28344
2    34343
2    29344
1    26344 

I just filter 2 (Count) values. How can I do this?

Thanks.


In Oracle we have to use GROUP BY with aggregate functions. When we want to filter by the aggregated result there is the HAVING clause:

select count(distinct tmr_id) ,CONTRACT_ID 
from status_handling
group by CONTRACT_ID 
having count(distinct tmr_id) = 2
/
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜