I have been banging my head over this one for quite a while now but can not seem to get it working :(
I have a table which among other standard fields, also has a few fi
SELECT
COUNT(DISTINCT val_1) AS val_1_count,
COUNT(DISTINCT val_2) AS val_2_count,
...
FROM ...
will give you the counts for each field.
SELECT val_1, count(*) as val_1_count
FROM ...
GROUP BY val_1
will give you the counts for a value. You can use UNION to repeat this for val_1 to val_n in a single (kludgy) query.
If you want the counts over all fields, you need
SELECT val,count(*) as valcount
FROM (
SELECT val_1 AS val FROM ...
UNION ALL
SELECT val_2 AS val FROM ...
...
) AS baseview
GROUP BY val