-
Notifications
You must be signed in to change notification settings - Fork 2
/
All_Political_Follower_Sentiment_Summary.sql
27 lines (26 loc) · 1.4 KB
/
All_Political_Follower_Sentiment_Summary.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
Select Candidate,
Format(Count(*),'N0') As Tweets,
Format(Count(Distinct Tweeter_Id),'N0') As Tweeters,
dbo.Significant_Digits_String(100*Avg(MSFT_Sentiment),2)+'%' As [Avg % Chance Pos (MSFT)],
dbo.Significant_Digits_String(Avg(TextBlob_Sentiment),2) As [Avg Sentiment (Textblob)],
dbo.Significant_Digits_String(100.*Sum(Case When MSFT_Sentiment Between 1./3 And .4 Then 1. Else 0. End)/Count(*),2)+'%' As [% Low Chance Pos (MSFT)],
dbo.Significant_Digits_String(100.*Sum(Case When MSFT_Sentiment < 1./3 Then 1. Else 0. End)/Count(*),2)+'%' As [% Very Low Chance Pos (MSFT)],
dbo.Significant_Digits_String(100.*Sum(Case When TextBlob_Sentiment Between -.75 And -.5 Then 1. Else 0. End)/Count(*),2)+'%' As [% Negative (TextBlob)],
dbo.Significant_Digits_String(100.*Sum(Case When TextBlob_Sentiment < -.75 Then 1. Else 0. End)/Count(*),2)+'%' As [% Very Negative (TextBlob)]
From
(Select Distinct Candidate,Tweeter_Id,Tweet.Id,MSFT_Sentiment,TextBlob_Sentiment
From Tweet with (nolock)
Inner Join
[Following] with (nolock)
On Tweeter_Id=Follower
Inner Join
[User] with (nolock)
On [User].Id=Followee
Where Computed=1
And [User].Politician=1
) Temp
Group By Candidate
Order By Sum(Case When MSFT_Sentiment < 1./3 Then 1. Else 0. End)/Count(*) Desc
Select Count(*) As [Scored Tweets],Count(Distinct Tweeter_Id) As [Scored Tweeters]
From Tweet with (nolock)
Where Computed=1