-1

I want to sort the results in a descending order of the total number of times each statement has been executed.

Statements executed:

SELECT CONVERT (argument USING utf8)
FROM mysql.general_log
WHERE argument LIKE '%SELECT%' 
OR argument LIKE '%INSERT%' 
OR argument LIKE '%DELETE%' 
OR argument LIKE '%UPDATE%';
Ken White
  • 123,280
  • 14
  • 225
  • 444
c_minn
  • 1
  • 2
  • You can't get the number of times without using `COUNT()`, and to do that you'll need a `GROUP BY`, and then to sort, you'll need an `ORDER BY`. – Ken White Nov 20 '21 at 05:20

1 Answers1

0

Try

SELECT argument, count(*) FROM mysql.general_log WHERE argument LIKE '%SELECT%' OR argument LIKE '%INSERT%' OR argument LIKE '%DELETE%' OR argument LIKE '%UPDATE%' GROUP BY argument ORDER BY count(*) desc

Svein Terje Gaup
  • 1,424
  • 15
  • 29