I have a solution which I'm half-heartedly happy with:

[CODE]
sql_query = 'SELECT A1.value Value, COUNT(A1.value)' + '"Frequency"'
sql_query = sql_query + ' , A1.category Category'
sql_query = sql_query + ' FROM popularity A1'
sql_query = sql_query + ' WHERE Category = ' + test + ' GROUP BY A1.value'
[/CODE]

New solution:
[CODE]
sql_query = 'SELECT A1.value Value, COUNT(A1.value)' + '"Frequency"' \

  • ', A1.category Category' + ' FROM popularity A1' + ' WHERE Category = ' \
  • test + ' GROUP BY A1.value'
    [/CODE]
    ^ That one looks better, I think it might be the best I can get. Though, I'll still take suggestions.