使用Stack Exchange Data Explorer(SEDE)按帖子数和信誉查找用户

时间:2018-10-31 11:59:29

标签: sql sql-server-2017 dataexplorer

我想找出哪些用户的信誉最高,帖子数量最少(少于10个)。但是为什么在加入之前我不能拥有where子句? :

SELECT TOP 100 Users.Id, Users.DisplayName AS [Username], Users.Reputation, COUNT(Posts.Id) AS [Post Count] FROM Users
//WHERE COUNT(Posts.Id) < 10
JOIN Posts ON Posts.OwnerUserId = Users.Id 
GROUP BY Users.Id, Users.DisplayName, Users.Reputation
ORDER BY Users.Reputation DESC;

原始用户帖子数示例查询位于data.stackexchange.com/stackoverflow/query/503051

1 个答案:

答案 0 :(得分:1)

这就是the HAVING clauseMS reference)的目的。

您将使用:

Obj

但是就在这里,利用了几个SEDE features

var Obj = {
    h(x, y) {
        return x + y;
    },
    slow(x, y) {
        alert('called slow function with ' + x + ', ' + y);
        return x * y * this.h(x, y)
    }
}

function c (func){
    var cache = {};
    return function(x, y){
        if (!cache[[x, y]]){
            cache[[x, y]] = func(x, y);
        }
        return cache[[x, y]];
    }
}
Obj.slow = Obj.slow.bind(Obj); // You have to bind the object slow method to object context

Obj.slow = c(Obj.slow);
alert(Obj.slow(1, 4));
alert(Obj.slow(1, 2));
alert(Obj.slow(1, 4));
alert(Obj.slow(1, 3));
alert(Obj.slow(1, 2));
alert(Obj.slow(1, 3));

您可以see it live in SEDE

我特别喜欢the users with higher rep that have no posts