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
How many restaurant are there in the Hazelwood district of Dallas ?
assistant
SELECT COUNT ( DISTINCT t1.name ) FROM category AS t3 JOIN business AS t1 ON t3.business_id = t1.business_id JOIN neighbourhood AS t2 ON t2.business_id = t1.business_id WHERE t1.city = 'Dallas' AND t3.category_name = 'restaurant' AND t2.neighbourhood_name = 'Hazelwood';
human
what is the number of restaurant in Texas
assistant
SELECT COUNT ( DISTINCT t1.name ) FROM category AS t2 JOIN business AS t1 ON t2.business_id = t1.business_id WHERE t1.state = 'Texas' AND t2.category_name = 'restaurant';
human
Find all Mexican restaurant in Dallas with at least 3.5 stars
assistant
SELECT t1.name FROM category AS t2 JOIN business AS t1 ON t2.business_id = t1.business_id JOIN category AS t3 ON t3.business_id = t1.business_id WHERE t1.city = 'Dallas' AND t1.rating > 3.5 AND t2.category_name = 'Mexican' AND t3.category_name = 'restaurant';
human
Find all Dallas restaurant with a rating above 4.5
assistant
SELECT t1.name FROM category AS t2 JOIN business AS t1 ON t2.business_id = t1.business_id WHERE t1.city = 'Dallas' AND t1.rating > 4.5 AND t2.category_name = 'restaurant';
human
Find all restaurant reviewed by Patrick in ' Dallas '
assistant
SELECT t1.name FROM category AS t2 JOIN business AS t1 ON t2.business_id = t1.business_id JOIN review AS t3 ON t3.business_id = t1.business_id JOIN USER AS t4 ON t4.user_id = t3.user_id WHERE t1.city = 'Dallas' AND t2.category_name = 'restaurant' AND t4.name = 'Patrick';
human
Find all restaurant with Valet Service in Dallas Texas
assistant
SELECT t1.name FROM category AS t2 JOIN business AS t1 ON t2.business_id = t1.business_id JOIN category AS t3 ON t3.business_id = t1.business_id WHERE t1.city = "Dallas" AND t1.state = "Texas" AND t2.category_name = "Valet Service" AND t3.category_name = "restaurant" ;