SELECT uid , displayname , MAX(CASE WHEN rn = 10 THEN pi...

0

Please login or register to vote for this query.

(click on this box to dismiss)

Open Source Meta

Q&A about the site for people organizing, marketing or licensing open source development projects

SELECT
    uid
  , displayname
  , MAX(CASE WHEN rn = 10  THEN pid END) AS pid10
  , MAX(CASE WHEN rn = 100 THEN pid END) AS pid100
FROM (
    SELECT
        u.Id                                                AS uid
      , u.DisplayName
      , p.Id                                                AS pid
      , ROW_NUMBER() OVER (PARTITION BY u.Id ORDER BY p.id) AS rn
    FROM Users AS u
    LEFT JOIN Posts AS p ON u.Id = p.OwnerUserId
    ) AS up
WHERE (
        rn IN (10, 100)
     OR rn IS NULL
      )
GROUP BY
    uid
  , displayname

Enter Parameters

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