SELECT COUNT("Nr.") "quantity", "Sys." FROM "searchtable" WHERE "Nr."IN ( SELECT "searchtable"."Nr." FROM "filter", "searchtable" WHERE "searchtable"."Art" = IFNULL( "filter"."filter_2", "searchtable"."Art" )) GROUP BY "Sys." ORDER BY "Sys."ASC
SELECT COUNT("Nr.") "quantity", "Art" FROM "searchtable" WHERE "Nr."IN ( SELECT "searchtable"."Nr." FROM "filter", "searchtable" WHERE "searchtable"."Sys." = IFNULL( "filter"."filter_1", "searchtable"."Sys." )) GROUP BY "Art" ORDER BY "Art"ASC