Sto provando a scrivere un Quanto ho digitato? query su Stack* Data Explorer.Cosa c'è di sbagliato in questa query SQL Data Explorer?
Modifica di una query esistente me questo ha ottenuto di gran lunga:
-- 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'
mi aspetto tre colonne e una riga, qualcosa di simile:
Posts Comments Total
1234 5678 6912
ma c'è qualche problema di sintassi, a causa della quale ottengo:
Error: Incorrect syntax near ','. Incorrect syntax near ','. Incorrect syntax near the keyword 'select'. Incorrect syntax near ')'.
Qual è la sintassi corretta per questo?
La domanda riguarda http://odata.stackexchange.com/stackoverflow/query/new in particolare. Le query SQL a caso non aiutano. –
@ Aaron Harun: cosa stanno facendo tutti sbagliati? È come Data Explorer supporta solo un sottoinsieme di query SQL valide? – Lazer
Fondamentalmente, sì. Devono usare TSQL, ma alcuni non lo sono. (http://www.devguru.com/technologies/t-sql/home.asp) Nella maggior parte degli esempi "sbagliati", ci sono errori di sintassi e altri hanno usato nomi di campo diversi. * scrollando le spalle * Succede. –