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
What is the total likes on tips from Niloofar
assistant
SELECT SUM ( t1.likes ) FROM USER AS t2 JOIN tip AS t1 ON t2.user_id = t1.user_id WHERE t2.name = 'Niloofar';
human
Find all reviews by Patrick with a rating above 4
assistant
SELECT t1.text FROM USER AS t2 JOIN review AS t1 ON t2.user_id = t1.user_id WHERE t1.rating > 4 AND t2.name = 'Patrick';
human
list all the businesses which Niloofar rated 5
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 t2.rating = 5 AND t3.name = 'Niloofar';
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
How many reviews has Niloofar written in 2015
assistant
SELECT COUNT ( DISTINCT t1.text ) FROM USER AS t2 JOIN review AS t1 ON t2.user_id = t1.user_id WHERE t1.year = 2015 AND t2.name = 'Niloofar';
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" ;