Skip to content

Commit 484a608

Browse files
committed
adding sql problems
1 parent 1522f3b commit 484a608

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

39.1 Yelp Top Cool Votes problem.sql

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#Top Cool Votes
2+
#Find the review_text that received the highest number of 'cool' votes
3+
#Output the business name along with the review text with the highest numbef of 'cool' votes.
4+
5+
select business_name,review_text from
6+
(select business_name,review_text,cool,
7+
dense_rank() over(order by cool desc) as rnk
8+
from yelp_reviews) sub
9+
where rnk=1
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#link https://platform.stratascratch.com/coding/9915-highest-cost-orders?python=
2+
#Q. Highest Cost Orders
3+
4+
#Find the customer with the highest daily total order cost between 2019-02-01 to 2019-05-01.
5+
#If customer had more than one order on a certain day, sum the order costs on daily basis. Output their
6+
#first name, total cost of their items, and the date.
7+
#For simplicity, you can assume that every first name in the dataset is unique.
8+
select first_name,total_order_cost,order_date
9+
from
10+
(select first_name,
11+
sum(total_order_cost) total_order_cost,
12+
order_date
13+
,rank() over(order by sum(total_order_cost) desc) rnk
14+
from customers c join orders o
15+
on c.id= o.cust_id
16+
where order_date between '2019-02-01' and '2019-05-01'
17+
group by first_name, order_date) sub
18+
where rnk=1;

0 commit comments

Comments
 (0)