Top Businesses With Most Reviews

Find the top 5 businesses with most reviews. Assume that each row has a unique business_id such that the total reviews for each business is listed on each row. Output the business name along with the total number of reviews and order your results by the total reviews in descending order.

table name: yelp_business

Solution:
select top 5 name,review_count from yelp_business order by review_count desc

Output:
SQL Script:
CREATE TABLE [dbo].[yelp_business](
[business_id] [varchar](50) NOT NULL,
[name] [varchar](50) NULL,
[neighborhood] [varchar](50) NULL,
[address] [varchar](550) NULL,
[city] [varchar](50) NULL,
[state] [varchar](50) NULL,
[postal_code] [varchar](50) NULL,
[latitude] [float] NULL,
[longitude] [float] NULL,
[stars] [float] NULL,
[review_count] [int] NULL,
[is_open] [int] NULL,
[categories] [varchar](550) NULL,
 CONSTRAINT [PK_yelp_business1] PRIMARY KEY CLUSTERED 
(
[business_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
GO


Comments (0)