Did you check What cool data explorer queries have you come up with?
The queries you see in the dashboard are here discourse/app/models/concerns/reports at 1472e47aae5bfdfb6fd9abfe89beb186c751f514 · discourse/discourse · GitHub but you’d need to dig a bit in the ruby code to extract the SQL query.