I have a database (lets call it DB) containing 150+ tables, (eg: table1, table2 etc.)
Problem
I want to loop through all tables and get count of rows by groups, as below
Current Approach
As of now I was thinking of appending all tables or doing so manually!
Table structure
name code
A code1
A code2
A code6
A code98
B code1
Expected Output
table_name name code count
table1 A code1 100
table1 B code2 941
table2 A code1 98
Code for each table
SELECT name, code, count (*) AS count
FROM table1
GROUP BY name, code