Where can I find a syntax or language reference for the query language used on https://data.stackexchange.com/?
1 Answer
The Stack Exchange Data Explorer now has a tutorial to get you started, the help states that SEDE runs on Microsoft SQL Server.
I've also created this pull request, as suggested by Monica Cellio, that will add on the Next Steps page of the tutorial a reference to the Microsoft T-SQL language. That PR was deployed in revision 2020.12.13.80.
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 2019 (RTM-CU9) (KB5000642) - 15.0.4102.2 (X64).
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)
-
2Unless I'm missing something, the SEDE tutorial doesn't actually say that the language is T-SQL, does it? That seems like vital information.– David ZAug 21, 2016 at 8:02
-
-
@DavidZ oops, good catch. We'll fix that when we next update the tutorial. Aug 21, 2016 at 17:55
site://
thing, magic columns and all that weird stuff. I think someone mentioned a graphing function once as well.select (*) from Users where LastAccessDate >= (Now - 90)
(active users in last 90 days), but have no idea what the correct function words are.