What is meta? ×
Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 130 Stack Exchange communities.

I am basically a C programmer but I started on SQL today with the only purpose of fiddling around the data available on data.stackexchange.com. So please bear with me if my question is naive or unclear. I wrote a query to find out Popular Questions on SO based on view count

Select 
    OwnerUserId As [User Link],
    Id As [Post Link],
    ViewCount As [Total Number of Views]
From 
    Posts
Where
    ViewCount > 10000

Order By
    ViewCount Desc

The problem I am facing here is if I change [Post Link] to [Popular Question] or [User Link] to something more desirable like [Asker], the hyper-links linking to the question and the user receptively don't appear. Only IDs of users and Posts like 457237(my user id), 145275(this question ID) appear. If I understand correctly AS is just an ALIAS.

So how is that [Post Link] produces a hyperlink and [Link to the Question] or something else doesn't?

Is it something specific to data.stackexchange?

share|improve this question

1 Answer 1

up vote 6 down vote accepted

Yes, Data Explorer has a number of "magic" columns that will do transformations on the data returned in the result set, where appropriate.

The magic columns currently defined are as follows:

  • [Post Link] - Turns a post ID field into a link to the relevant question/answer
  • [User Link] - Turns a user ID field into a link to the relevant user
  • [Comment Link] - Turns a comment ID into a link to the relevant comment
  • [Suggested Edit Link] - Turns a suggested edit ID into a link to the relevant suggested edit (although I suspect there may be problems with this one on account of the new review route...)

Automatic transformation is also done on [Tag] and [TagName] fields to generate tag-styled links to the relevant tag pages.

If you want to use custom column aliases, you can build the links manually, although it requires you to pull all of the relevant information yourself. For information about more easily creating site-specific links yourself, take a look at this answer and the linked example query.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .