Article From:

Now there are two tables
ATable (questionnaire): ID, title
BTable (questionnaire completed by users): ID,, user_id

Now we need to count the number of users answered by each questionnaire. How do we do this?

I can do two queries, but one sentence is not acceptable.

Forget to say, B table data is not necessarily

Answer 0:

select title, count(user_id) total from a left join b on group by(b.aid) order by total DESC

bIs there any data that does not affect the table

Leave a Reply

Your email address will not be published. Required fields are marked *