Closed ericberman closed 4 years ago
Flights per user can be done with this query (ignores new users): select count(f2.usercount), f2.numflights FROM (select u.username as usercount, floor((count(f.idflight) + 99) / 100) * 100 as numflights from users u left join flights f on u.username=f.username group by u.username order by numflights asc) f2 group by f2.numflights order by f2.numflights asc;
But new users can be done by repeating the query with a "where" clause on f2
Note that the above query requires adjusting buckets. 0, 1-100, 101-200, ... (instead of 1-99, 100-199, etc.)
I don't know what this is about ....
nope, I don't expect you would. I have a whole admin tab you've never seen, with lots of admin-only functions. One is a stats page, which works fine but has a slow query that shows me new users per month and a very very slow query for showing me number of flights per user; both were written like 10+ years ago. Since then, I have implemented a whole "IHistogramable" interface (which I use for Logbook->Analysis) that does the sort of pivot-table/bucketing that the analysis tab does, and with far simpler MySQL queries. This issue is for me to rip out the old code and replace it with the new code.
👍
for users: select date_format(creationdate, '%Y-%m') AS creationbucket, count(*) as numusers from users group by creationbucket order by creationbucket asc