human
Schema:
item (i_id, title)
review (a_id, u_id, i_id, rating, rank)
useracct (u_id, name)
trust (source_u_id, target_u_id, trust)
Please answer with SQL.
assistant
Sure, I understand.
human
Which id has the least rating on the table? | Which id do you need, a id, u id, or i id? | i id
assistant
SELECT i_id FROM review ORDER BY rating LIMIT 1;
human
For each user, find their name and the number of reviews written by them.
assistant
SELECT T1.name , COUNT( * ) FROM useracct AS T1 JOIN review AS T2 ON T1.u_id = T2.u_id GROUP BY T2.u_id;
human
Which u id has the least rank on the list?
assistant
SELECT u_id FROM review ORDER BY rank LIMIT 1 ;