How to get tweets under topic and also the status whether the logged in user reported the tweet or not in sql server

 ALTER PROCEDURE [dbo].[SP_GETTWEETSBYTOPIC_REPORTEDSTATUS]

@TopicId INT,

@UserId INT

AS

BEGIN

select distinct tw.TweetId,tw.Id,tw.CreatedOn,

tw.TwitterHandle,tw.TwitterProfileLink,tw.Tweet,tw.TweetedOn,tw.Rating,

tw.NoofComments,tw.NoofLikes,tw.NoofReTweets,tw.IsActive,

(select

case

when ogr.userid IS NOT NULL and ogr.TweetId IS NOT NULL then CAST(1 AS BIT)

else CAST(0 AS BIT)

end as isreported ) IsReported from tweets tw

inner join tweettopic tt

on

tt.twtid=tw.id

left join ongoingreports ogr

on

ogr.TweetId=tw.TweetId and ogr.UserId=@UserId

where tt.TopicId=@TopicId and tw.IsActive=1 and  (UPPER(tw.Rating)='NEGATIVE' OR UPPER(tw.Rating)='FALSE')

END

Comments

Popular posts from this blog

Top MNC Interview Questions- Full Stack Developer

Interview Questions-2

How to get the user details, user current level, next level, Rank in sql server