Count for all table
I have 10 tables. I want count, sum, group, min, max and average for each table. Right now I am running below scripts one by one for each table. I wonder if it possible to run the script for all the tables. -- Count of record Select count(*) as RecordsTotal From table1 Where substring(ID,12,1)='9' and Year > '2016' -- Sum of Pages Select sum(cast(pages as INT) as PageCount from table1 Where substring(ID,12,1)='9' and Year > '2016' --Group by pages (0-25, 25-50,.....) Select sum(cast(pages as INT) as Rage from table1 Where substring(ID,12,1)='9' and Year > '2016' Group by --Min Select Min(cast(pages as INT) as minPages from table1 Where substring(ID,12,1)='9' and Year > '2016' --Max Select Min(cast(pages as INT) as maxPages from table1 Where substring(ID,12,1)='9' and Year > '2016' --AVG Select AVG(cast(pages as INT) as AVGPages from table1 Where substring(ID,12,1)='9' and Year > '2016'