Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 18095

SQL counting user numbers above a certain percentage threshold of consumption

$
0
0

Im tring to run this code to find the number of users in usa who made more than 10% of their phone calls in english. I think the code makes sense but I get an error when I run it. Is the problem the "Having" statement? Its one table, with columns being user_id, country, call duration, number of calls

SELECT     count(distinct user_id),(      SELECT (COUNT(*)                 FROM table                WHERE language = 'en' AND country = 'usa')/                SELECT (COUNT(*) FROM table * 100                ) AS Percentage    FROM table    HAVING percentage > 10

Viewing all articles
Browse latest Browse all 18095

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>