Useful SQL Queries

This Page is more or less targeted at ToS;DR Staff with access to Production or Staging Databases.

Though they may be useful for anyone self hosting Phoenix as well.

Top 10 Services with most approved points

SELECT COUNT(POINTS.ID) AS POINTSUM,
	SERVICES.NAME As SERVICENAME,
	SERVICES.RATING
FROM POINTS
INNER JOIN SERVICES ON POINTS.SERVICE_ID = SERVICES.ID
WHERE POINTS.STATUS = 'approved'
GROUP BY SERVICES.ID
ORDER BY POINTSUM DESC
LIMIT 10

Get amount of services a rating has

Excluding N/A Ratings

Top 10 Services on ToS;DR with the “highest” possible rating.

Counts all Services with an “A” rating and the most “good” cases.

Top 10 Services on ToS;DR with the “worst” possible rating.

Counts all Services with an “E” rating and the most “bad” and “blocker” cases