我想找出哪些用户的信誉最高,帖子数量最少(少于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
答案 0 :(得分:1)
这就是the HAVING
clause(MS 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));