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
What is the average rating of all items?
assistant
SELECT AVG ( rating ) FROM review;
human
How many items have a rating lower than the average?
assistant
SELECT COUNT( * ) FROM item AS T1 JOIN review AS T2 ON T1.i_id = T2.i_id WHERE T2.rating < ( SELECT AVG ( rating ) FROM review );
human
How about higher than the average?
assistant
SELECT COUNT( * ) FROM item AS T1 JOIN review AS T2 ON T1.i_id = T2.i_id WHERE T2.rating > ( SELECT AVG ( rating ) FROM review );
human
What are the names of those items?
assistant
SELECT T1.title FROM item AS T1 JOIN review AS T2 ON T1.i_id = T2.i_id WHERE T2.rating > ( SELECT AVG ( rating ) FROM review ) ;