questions_query = \
"""
SELECT id, title, owner_user_id
FROM `bigquery-public-data.stackoverflow.posts_questions`
WHERE tags LIKE '%bigquery%'
"""
answers_query = \
"""
SELECT pa.id, pa.body, pa.owner_user_id
FROM `bigquery-public-data.stackoverflow.posts_questions` AS pq
INNER JOIN `bigquery-public-data.stackoverflow.posts_answers` AS pa
ON pq.id = pa.parent_id
WHERE pq.tags LIKE '%bigquery%'
"""
bigquery_experts_query = \
"""
SELECT pa.owner_user_id AS user_id, COUNT(1) AS number_of_answers
FROM `bigquery-public-data.stackoverflow.posts_questions` AS pq
INNER JOIN `bigquery-public-data.stackoverflow.posts_answers` AS pa
ON pq.id = pa.parent_id
WHERE pq.tags LIKE '%bigquery%'
GROUP BY pa.owner_user_id
HAVING number_of_answers > 0
"""
query = f"""
SELECT pa.owner_user_id AS user_id, COUNT(1) AS number_of_answers
FROM `bigquery-public-data.stackoverflow.posts_questions` AS pq
INNER JOIN `bigquery-public-data.stackoverflow.posts_answers` AS pa
ON pq.id = pa.parent_id
WHERE pq.tags LIKE '%{topic}%'
GROUP BY pa.owner_user_id
ORDER BY number_of_answers DESC
"""