我想寫一個我輸入了多少?查詢Stack* Data Explorer。此數據資源管理器SQL查詢有什麼問題?
修改現有的查詢讓我這麼遠:
-- How much did I type?
DECLARE @UserId int = ##UserId##
select sum(len(Body)) AS 'Posts' from posts where owneruserid = @UserId,
select sum(len(Text)) AS 'Comments' from comments where userid = @UserId,
(select sum(len(Body)) from posts where owneruserid = @UserId +
select sum(len(Text)) from comments where userid = @UserId) AS 'Total'
我期待着三列一列,這樣的事情:
Posts Comments Total
1234 5678 6912
但是有一些語法問題,由於其我得到:
Error: Incorrect syntax near ','. Incorrect syntax near ','. Incorrect syntax near the keyword 'select'. Incorrect syntax near ')'.
這是什麼正確的語法?
問題是關於http://odata.stackexchange.com/stackoverflow/query/new具體。隨機SQL查詢沒有幫助。 – 2010-06-25 06:13:29
@Aaron Harun:大家做錯了什麼?它是否像Data Explorer僅支持有效的SQL查詢的子集? – Lazer 2010-06-25 06:25:55
基本上,是的。他們需要使用TSQL,但有些則不是。 (http://www.devguru.com/technologies/t-sql/home.asp)在大多數「錯誤」的例子中,有語法錯誤和其他使用不同字段名稱的例子。 *聳聳肩*它發生。 – 2010-06-25 06:31:59