SQL query: max group with all info == x, grouped by value

I have the following database:

addition
questionId | answerId | info


question
id | num_a | num_b

I am trying to get max(num_a) where all the questions with this num_a have info == 3

I've tried this so far;

query = ('SELECT MAX(qu.number_a) '
         f'FROM {table} tb '
         'INNER JOIN question qu ON qu.id = tb.question_id '
         'WHERE tb.info == 3 '
         'GROUP BY qu.number_a')


Read more here: https://stackoverflow.com/questions/64950301/sql-query-max-group-with-all-info-x-grouped-by-value

Content Attribution

This content was originally published by Sy Ker at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: