I have a table (People) with these columns
Gender
Name
Address
Employment
Education
I want a query that will output the percent null rate for all columns while grouping by [Gender] column.
The table I am using has 60 columns so I do not want to hard code the columns. I am using the above just as an example.
I am expecting output similar to this. The figures are percent null rate
| Gender | Name | Address | Employment | Education |
| ------------ | ------------ | ------------ | ------------ | ------------ |
| Male | 0.2365 | 0.5642 | 0.3652 | 0.1563 |
| Female | 0.5263 | 0.3265 | 0.5214 | 0.1563 |
1条答案
按热度按时间vktxenjb1#
Can use the
INFORMATION_SCHEMA.COLUMNS
table to get the columns, then from there it is just a matter of constructing your dynamic query.This constructs and executes a query similar to this: