Find the review_text that received the highest number of 'cool' votes.
Output the business name along with the review text with the highest numbef of 'cool' votes.
table name: yelp_reviews
CREATE TABLE [dbo].[yelp_reviews](
[business_name] [varchar](150) NULL,
[review_id] [varchar](50) NULL,
[user_id] [varchar](50) NULL,
[stars] [varchar](50) NULL,
[review_date] [datetime] NULL,
[review_text] [varchar](550) NULL,
[funny] [int] NULL,
[useful] [int] NULL,
[cool] [int] NULL
) ON [PRIMARY]
Solution:
select top 1 with ties business_name,review_text from yelp_reviews
group by business_name,review_text order by sum(isnull(cool,0)) desc
select business_name,review_text
from yelp_reviews
where cool = (select max(cool) from yelp_reviews)
Output: