I'm playing with some dynamic sql like this:
DECLARE columns STRING;
SET columns = (
STRING_AGG(CONCAT('COUNT(DISTINCT `', column_name, '`) AS ', column_name, '_count'))
table_name = "<name>"
But when I highlight the whole code and execute I'm getting Undeclared variable: columns. Is it because it's sent as separate queries?