Skip to content

Instantly share code, notes, and snippets.

@regme
Created April 10, 2019 14:08
Show Gist options
  • Save regme/462ccc42e059dfa565a30ce2a199118f to your computer and use it in GitHub Desktop.
Save regme/462ccc42e059dfa565a30ce2a199118f to your computer and use it in GitHub Desktop.
Indicators histogram
select ind.NewsHeadlinesIndicatorId, ind.Title, ii.cnt from NewsHeadlinesIndicator ind
join (
select NewsHeadlinesindicatorId, count(*) as cnt from (
SELECT [NewsHeadlinesIndicatorId]
,[FundId]
,[EventDTM]
,[NewsHeadlinesZoneId]
,[Trend]
,[OccurrencesTotal]
,[OccurrencesChecked]
,[PeriodLength]
,[Weight]
,[Gain]
,RANK() over (partition by FundId order by Weight desc) as rn
FROM [dbo].[NewsHeadlines]
) i where i.rn = 1
group by NewsHeadlinesIndicatorId
) ii
on ind.NewsHeadlinesIndicatorId = ii.NewsHeadlinesIndicatorId
order by 3 desc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment