0

I have several tables all of which have the column LOCQUALITY. There are about 10 different values for LOCQUALITY. I want to know the percentage of the LOCQUALITY field from all the tables combined. I have been using these two queries:

Select LOCQUALITY, (Count(LOCQUALITY)* 100 / (Select Count(*) From TSDBA.TS_LOCATION))
From TSDBA.TS_LOCATION
Group By LOCQUALITY

This one gets the percentage of just one table. I go it from here How to calculate percentage with a SQL statement

And I used this one to determine which are the tables that have the LOCQUALITY column (It returned like 30 tables). Got it from here Find all tables containing column with specified name

SELECT COLUMN_NAME, TABLE_NAME 
FROM INFORMATION_SCHEMA.COLUMNS 
WHERE COLUMN_NAME LIKE '%LOCQUALITY%'

I want to combine these two but I have only gotten errors. Thanks for your help

Community
  • 1
  • 1
David Guzmán
  • 25
  • 1
  • 9
  • I removed the SQL Server tag because the syntax suggests MySQL. – Gordon Linoff Apr 01 '16 at 18:53
  • you are going to do it by hand -- you can't pick which tables to select from in a select statement without dynamic sql. But your percentage calculation does not make sense. – Hogan Apr 01 '16 at 19:09

0 Answers0