1st task

0

Please login or register to vote for this query.

(click on this box to dismiss)

CiviCRM Meta

Q&A about the site for administrators and users of the CiviCRM Constituent Relationship Management software

/*select top 100 * from VoteTypes;
select top 100 * 
from Votes 
where PostId = 356123;
select cont(v.Id), v.PostId, vt.Name
from Votes v,
     VoteType vt
where v.VoteTypeId = vt.Id
and vt.Name in ('UpMode','DownMode')

select top 10 v.PostId, vt.Name
    from Votes v,
         VoteTypes vt
    where v.VoteTypeId = vt.Id
    and vt.Name = 'UpMode'*/

with rankedupvotes as (
    select top 10 count(v.Id) VoteCount, v.PostId, vt.Name
    from Votes v,
         VoteTypes vt
    where v.VoteTypeId = vt.Id
    and vt.Name = 'UpMod'
    group by v.PostId, vt.Name
    order by count(v.Id) desc

),
rankeddownvotes as (
    select top 10 count(v.Id) VoteCount, v.PostId, vt.Name
    from Votes v,
         VoteTypes vt
    where v.VoteTypeId = vt.Id
    and vt.Name = 'DownMod'
    group by v.PostId, vt.Name
    order by count(v.Id) desc

)
select PostId, Name, VoteCount
from rankedupvotes

union all

select PostId, Name, VoteCount
from rankeddownvotes;

Enter Parameters

Options:
Switch to main site
loading Hold tight while we fetch your results