question

simam-9471 avatar image
0 Votes"
simam-9471 asked DSPatrick edited

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'

sql-server-transact-sql
· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi,
what tables did you mean?

0 Votes 0 ·

Would you mind post back your script?
Are you using PowerShell script?

0 Votes 0 ·

0 Answers