The below query explains how to find a tie between rating of 2 products. For example out of given 5 product rating on an ecommerce web site you need to find the top 2 rating prodcuts(brand) what if 2 products(brands) have same rating and are equally placed in 2nd position? Use the below query to solve the problem.
create table product-- Create a table product with brand,rating and price as variables--
(brand varchar(50),rating int,price int)
select * from product
Out put// You will get the output as shown below//

Insert the number of values(5 in this case) required in the table
-- after inserting the values to find the top2 rating use the below query--
select * from product
select top 2 with ties * from product -- using ties here gives you 3 values even if you are lo0king for only 2 values with higher rating as rating of brands are equal for 2n and 3rd// if you do not use tie you will get only 2 values--
where brand in (rating>=1)
order by rating asc-- this orders brands in ascending order as per the ratings--
create table product-- Create a table product with brand,rating and price as variables--
(brand varchar(50),rating int,price int)
select * from product
Out put// You will get the output as shown below//
Insert the number of values(5 in this case) required in the table
-- after inserting the values to find the top2 rating use the below query--
select * from product
select top 2 with ties * from product -- using ties here gives you 3 values even if you are lo0king for only 2 values with higher rating as rating of brands are equal for 2n and 3rd// if you do not use tie you will get only 2 values--
where brand in (rating>=1)
order by rating asc-- this orders brands in ascending order as per the ratings--


