0

I don't want to write a large query statement like

SELECT SUM(CASE WHEN column1 IS NULL THEN 1 ELSE 0),
       SUM(CASE WHEN column2 IS NULL THEN 1 ELSE 0),
       SUM(CASE WHEN column2 IS NULL THEN 1 ELSE 0),
....
FROM Table

Because there are almost 200 columns. And the result should show the amount of NULL distinct by column.

raushu
  • 61
  • 8
  • Possible duplicate of [Apply like over all columns without specifying all column names?](https://stackoverflow.com/questions/8815025/apply-like-over-all-columns-without-specifying-all-column-names) – hakamairi Feb 28 '19 at 08:31
  • @hakamairi That's for SQL server, not sqlite or MySQL. OP: which database are you using? Only tag that one instead of multiple different ones. – Shawn Feb 28 '19 at 08:41
  • @Shawn, general approach would be exactly the same, right? – hakamairi Feb 28 '19 at 08:46
  • @hakamairi I think there are some differences between the two questions. The older question didn't solve my problem.Because what I am concerned is avoid writing a large SUM(...) statement. – raushu Feb 28 '19 at 08:49
  • @hakamairi Since most of the decent answers there involve things like stored procedures, no. – Shawn Feb 28 '19 at 09:00
  • @Shawn interesting, stored procedures actually might be the way (taking into account sqlite limitations those can be user defined function like https://stackoverflow.com/questions/24229785/sqlite-net-sqlitefunction-not-working-in-linq-to-sql/26155359#26155359). Lets see where it goes. – hakamairi Feb 28 '19 at 09:03
  • Just use a query or spreadsheet to write the query. The metadata tables have all the column names for the table. – Gordon Linoff Feb 28 '19 at 13:08

0 Answers0