WITH UserStats AS ( SELECT Users.Id AS UserId, COUNT(Post...

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 UserStats AS (
    SELECT
        Users.Id AS UserId,
        COUNT(Posts.Id) AS TotalPosts,
        SUM(Posts.Score) AS TotalPostScore,
        SUM(Posts.ViewCount) AS TotalViews,
        COUNT(PostComments.Id) AS TotalComments
    FROM Posts
    INNER JOIN Users ON Posts.OwnerUserId = Users.Id
    LEFT JOIN Comments AS PostComments ON Posts.Id = PostComments.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
    UserStats.UserId
FROM UserStats
WHERE 
    ABS(UserStats.TotalPosts - 214.742097) <= 10
    AND ABS(UserStats.TotalPostScore - 910.105657) <= 10
    AND ABS(UserStats.TotalViews - 2346.425125) <= 10
    AND ABS(UserStats.TotalComments - 194.200499) <= 10
ORDER BY UserStats.UserId;

Enter Parameters

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