I’m using the command
select video_info count(distinct src_ip) from videoinfo
group by video_info
order by count(distinct src_ip) DESC
to fetch 2 columns of data, the first column represents identifiers for each video items, the second column records how many times they have been downloaded.
I also want to calculate, for example, 5% of videos have been downloaded twice, 10% videos have been downloaded 10 times, then record the percentage numbers and the download times into two arrays.
Does Mysql support such calculation? or I need to switch to Python to do that? If so, how to do that in Python?
In Python you can use this:
With
counter = {'a': 1, 'b': 1, 'c': 2, 'd': 1, 'e': 2, 'f': 3}this prints: