我想写一个我输入了多少?查询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