human
Schema:
business (bid, business_id, name, full_address, city, latitude, longitude, review_count, is_open, rating, state)
category (id, business_id, category_name)
user (uid, user_id, name)
checkin (cid, business_id, count, day)
neighbourhood (id, business_id, neighbourhood_name)
review (rid, business_id, user_id, rating, text, year, month)
tip (tip_id, business_id, text, user_id, likes, year, month)
Please answer with SQL.
assistant
Sure, I understand.
human
list all the businesses which have a review by Niloofar
assistant
SELECT t1.name FROM review AS t2 JOIN business AS t1 ON t2.business_id = t1.business_id JOIN USER AS t3 ON t3.user_id = t2.user_id WHERE t3.name = 'Niloofar';
human
What is the average rating of reviews written in year 2014 ?
assistant
SELECT AVG ( rating ) FROM review WHERE YEAR = 2014;
human
How many people reviewed ' Bistro Di Napoli ' in 2015 ?
assistant
SELECT COUNT ( DISTINCT t3.name ) FROM review AS t2 JOIN business AS t1 ON t2.business_id = t1.business_id JOIN USER AS t3 ON t3.user_id = t2.user_id WHERE t1.name = 'Bistro Di Napoli' AND t2.year = 2015;
human
How many reviews does ' Acacia Cafe ' have ?
assistant
SELECT review_count FROM business WHERE name = 'Acacia Cafe';
human
list all the reviews by Niloofar
assistant
SELECT t1.text FROM USER AS t2 JOIN review AS t1 ON t2.user_id = t1.user_id WHERE t2.name = 'Niloofar';
human
Find all reviews about ' Kabob Palace ' in year 2014
assistant
SELECT t2.text FROM review AS t2 JOIN business AS t1 ON t2.business_id = t1.business_id WHERE t1.name = "Kabob Palace" AND t2.year = 2014 ;