By perfectly good sql query, I mean to say that, inside WebMatrix, if I execute the following query, it works to perfection:
SELECT page AS location, (len(page) - len(replace(UPPER(page), UPPER('o'), ''))) / len('o') AS occurences, 'pageSettings' AS tableName FROM PageSettings WHERE page LIKE '%o%'
UNION
SELECT pageTitle AS location,
…