l008com Posted November 24, 2008 Share Posted November 24, 2008 I've got a simple query that counts distinct items in a table SELECT COUNT(DISTINCT flag_rest_spam.msgid) FROM flag_rest_spam What I want to do is add a threshold to the count. What I mean is I want to count distinct items in the table, but i only want to count items that have more than N number of items. I'm not sure how to do this? Quote Link to comment https://forums.phpfreaks.com/topic/133969-count-distinct-with-a-threshold/ Share on other sites More sharing options...
xtopolis Posted November 24, 2008 Share Posted November 24, 2008 Off the top of my head, might be able to add a having clause SELECT COUNT(DISTINCT flag_rest_spam.msgid) as frs FROM flag_rest_spam HAVING frs > 5; Not sure. Quote Link to comment https://forums.phpfreaks.com/topic/133969-count-distinct-with-a-threshold/#findComment-697450 Share on other sites More sharing options...
fenway Posted November 25, 2008 Share Posted November 25, 2008 That's in fact the only legible way to do it. Quote Link to comment https://forums.phpfreaks.com/topic/133969-count-distinct-with-a-threshold/#findComment-699021 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.