我運行下面的SQL,但不斷收到錯誤: -SQL分組錯誤
'Column 'SRVS.dbo.BTQGLDistributionsWithProjectCodesHM.AccountNo' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.
我運行的代碼是: -
SELECT AccountNo,
TransDate,
JournalNo,
AuditTrail,
Description,
JnlAmount,
ACTINDX,
CONTRACTNAME,
PAPROJNUMBER,GROUPING(PAPROJNUMBER) as PAPROJNUMBER,
SUM(PAFeebillamount) as total
FROM SRVS.dbo.BTQGLDistributionsWithProjectCodesHM
GROUP BY PAPROJNUMBER with rollup
ORDER BY GROUPING (PAPROJNUMBER
任何人都可以點我在正確的方向上這個?
歡迎StackOverflow上:如果您發佈的代碼,XML或數據樣本,**請**在文本編輯器中高亮顯示這些行,並在編輯器工具欄上單擊「代碼樣本」按鈕(「{}」)以精確地格式化和語法突出顯示它!如果您發佈錯誤消息,請**使用blockquotes('「')正確格式化錯誤消息。 –