WITH UserAggregates AS ( SELECT Users.Id AS UserId, COUNT...

0

Please login or register to vote for this query.

(click on this box to dismiss)

Engineering

Q&A for professionals and students of engineering

WITH UserAggregates AS (
    SELECT
        Users.Id AS UserId,
        COUNT(Posts.Id) AS TotalPosts,
        SUM(Posts.Score) AS TotalPostScore,
        SUM(Posts.ViewCount) AS TotalViews,
        COUNT(Comments.Id) AS TotalComments
    FROM Posts
    INNER JOIN Users ON Posts.OwnerUserId = Users.Id
    LEFT JOIN Comments ON Posts.Id = Comments.PostId
    WHERE (
        Posts.Tags LIKE '%elementary-set-theory%'
        OR Posts.Tags LIKE '%real-analysis%'
        OR Posts.Tags LIKE '%calculus%'
        OR Posts.Tags LIKE '%linear-algebra%'
        OR Posts.Tags LIKE '%probability%'
        OR Posts.Tags LIKE '%abstract-algebra%'
        OR Posts.Tags LIKE '%integration%'
        OR Posts.Tags LIKE '%sequences-and-series%'
        OR Posts.Tags LIKE '%combinatorics%'
        OR Posts.Tags LIKE '%general-topology%'
        OR Posts.Tags LIKE '%geometry%'
        OR Posts.Tags LIKE '%number-theory%'
        OR Posts.Tags LIKE '%statistics%'
        OR Posts.Tags LIKE '%graph-theory%'
        OR Posts.Tags LIKE '%algebraic-geometry%'
        OR Posts.Tags LIKE '%differential-geometry%'
        OR Posts.Tags LIKE '%algebraic-topology%'
        OR Posts.Tags LIKE '%functional-analysis%'
        OR Posts.Tags LIKE '%complex-analysis%'
        OR Posts.Tags LIKE '%ring-theory%'
        OR Posts.Tags LIKE '%category-theory%'
        OR Posts.Tags LIKE '%set-theory%'
    )
    GROUP BY Users.Id
)
SELECT
    UserAggregates.UserId
FROM UserAggregates
WHERE 
    ABS(UserAggregates.TotalPosts - 214.742097) <= 10
    AND ABS(UserAggregates.TotalPostScore - 910.105657) <= 10
    AND ABS(UserAggregates.TotalViews - 2346.425125) <= 10
    AND ABS(UserAggregates.TotalComments - 194.200499) <= 10
ORDER BY UserAggregates.UserId;

Enter Parameters

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