Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 155 Stack Exchange communities.

What is meta?
Here's how it works:
  1. Any Stack Exchange user can ask a question
  2. The community provides support, votes on ideas, and reports bugs
  3. Your voice helps shape the way Stack Exchange operates

Where can I find a syntax or language reference for the query language used on http://data.stackexchange.com/?

share|improve this question
    
The language is T-SQL. – BoltClock's a Unicorn Jun 21 '12 at 20:54
    
It's just T-SQL. Are you asking about something beyond that? – Tim Stone Jun 21 '12 at 20:54
2  
Beyond that, a reference for all the special stuff might be useful as well. There's parameters, links, the site:// thing, magic columns and all that weird stuff. I think someone mentioned a graphing function once as well. – a cat Jun 21 '12 at 20:57
    
Here's the Database schema documentation for the public data dump and Data Explorer which can help. Also it has a faq which includes some interesting tidbits on magic aliases and parameters – Some Helpful Commenter Jun 21 '12 at 20:57
    
@Tim, that's the answer. I've never heard of TSQL. I was just trying to figure out how to write simple things like select (*) from Users where LastAccessDate >= (Now - 90) (active users in last 90 days), but have no idea what the correct function words are. – matt wilkie Jun 21 '12 at 21:01
    
@lunboks Updated help documentation is forthcoming, I promise. :P – Tim Stone Jun 21 '12 at 21:03

The Stack Exchange Data Explorer now has a help with the bare basics to get you started.

When creating a query the right side shows the tables and columns available. The functional details of the schema are described and updated here: Database schema documentation

The database is run on an instance of Microsoft Sql Server and therefor that sql dialect should be used, commonly known as T-SQL. The current version is Microsoft SQL Server 2012 (SP1).

Here is an example query to get you going and that demonstrates the features for parameters and magic links as well:

-- Score: Score on the post "a number"
-- UserId: Your User id "That is the id in url on the site"
select u.id as [User Link]
     , p.id as [Post Link]
     , c.id as [Comment Link]
from comments c 
inner join posts p on p.id = c.postid
inner join users u on p.owneruserid = u.id
where c.userid = ##UserId##
and p.score > ##Score:int?2##

Or this example that shows a nice graph (as seen in this answer by Shog9)

share|improve this answer

You must log in to answer this question.

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