So I recently have been working on a SEDE query that outputs posts from a given Stack Exchange site that have bodies of less than 50 characters.
While I have figured out how to get the links to those posts, I would also like to get the usernames under which those questions were posted.
Here is my current code:
SELECT p.Id AS [Post Link], Len(Body) AS [Body Length], p.Score, p.ViewCount, p.Tags
FROM Posts p
WHERE Len(Body) < 50
AND p.PostTypeId = 1
ORDER BY Len(Body) DESC
What I have tried to do to get my desired result:
p.OwnerUserId
does produce a new column, it only produces the given user IDs, while I would like the username specifically.p.OwnerUserId
to p.OwnerDisplayName
, this only produces a blank column with nothing in it.u.OwnerDisplayName
, it produces the errorLine 1: The multi-part identifier "u.OwnerDisplayName" could not be bound.
My question is: How can I also get the username of the original poster of the questions into its own column?
Revisions that include previous attempts (if it would be helpful to look at):
You just need to join to the Users
table:
SELECT p.Id AS [Post Link]
, u.DisplayName
, len(p.Body) AS [Body Length]
, p.Score
, p.ViewCount
, p.Tags
FROM Posts p
join
Users u on u.Id = p.OwnerUserId
WHERE len(p.Body) < 50
AND p.PostTypeId = 1
ORDER BY len(p.Body) DESC