-
Notifications
You must be signed in to change notification settings - Fork 0
/
Vine_Review_Analysis.sql
65 lines (53 loc) · 1.3 KB
/
Vine_Review_Analysis.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
Select *
Into Total_votes
From vine_table
Where total_votes >= 20;
Select *
Into helpful_votes_perc
From Total_Votes
Where Cast(helpful_votes AS FLOAT)/CAST(total_votes AS Float) >=0.5;
Select *
Into paid_vine
From helpful_votes_perc
Where vine = 'Y';
Select *
Into unpaid_vine
From helpful_votes_perc
Where vine = 'N';
Select Count (review_id)
From paid_vine;
Select Count (review_id)
From unpaid_vine;
Select COUNT (star_rating)
From paid_vine
Where star_rating = 5
limit 20
select *
from paid_vine
limit 50
with total as
(Select sum(total_votes) as totalvotes
From paid_vine),
stars as
(Select sum(total_votes) as totalvotes
From paid_vine
Where star_rating = 5)
Select total.totalvotes, stars.totalvotes as totalstars,
Round(Cast (stars.totalvotes as decimal)/Cast (total.totalvotes as decimal),2)
as paid_percentage
Into paid_perc
from total, stars
with total as
(Select sum(total_votes) as totalvotes
From unpaid_vine),
stars as
(Select sum(total_votes) as totalvotes
From unpaid_vine
Where star_rating = 5)
Select total.totalvotes, stars.totalvotes as totalstars,
Round(Cast (stars.totalvotes as decimal)/Cast (total.totalvotes as decimal),2)
as unpaid_percentage
Into unpaid_perc
from total, stars
select u.unpaid_percentage, p.paid_percentage
from unpaid_perc as u, paid_perc as p