我試圖創建一個有3列的查詢:1列代表列表作業數(不是空值),2°和第3列分別代表特定日期之前和之後的值之和具有多個值錯誤的子查詢。多列的案例
的SQL Server提供了一個錯誤,我真的不知道如何圍繞它的工作(除了不是創建2個查詢。)
SELECT
(SELECT
PiIndex
FROM
EleGcImpianti
WHERE
PiIndex IS NOT NULL) AS Commessa,
(SELECT
SUM(PrImportoDaFatturare)
FROM
EleGcPianificazioneRate
RIGHT OUTER JOIN
EleGcImpianti ON EleGcPianificazioneRate.PrIdImpianto = EleGcImpianti.PiId
WHERE
(EleGcPianificazioneRate.PrDataFattura <= CONVERT(datetime, '2014-01-01', 102))) AS [Somma Rate],
(SELECT
SUM(PrPercentualeDaFatturare)
FROM
EleGcPianificazioneRate
RIGHT OUTER JOIN
EleGcImpianti ON EleGcPianificazioneRate.PrIdImpianto = EleGcImpianti.PiId
WHERE
(PrDataFattura > CONVERT(datetime, '2014-01-01', 102))) AS [Somma Percentuale Rate]
錯誤說的是什麼? – MPelletier
您的sql語法無效 - 您只能使用子查詢指定select子句,但不指定表/視圖; – collapsar
此外,我懷疑你的第一個子查詢返回多個記錄,這也是不允許的 – Kostis