我的观点如下。
SELECT TOP (100) PERCENT 'SA' AS Doc_Type1, 'A' + SUBSTRING('000000', 1, 6 - LEN(CAST(dbo.companies.companyId AS varchar(10))))
+ CAST(dbo.companies.companyId AS varchar(10)) AS Client_ID, 1200 AS Bank_Nom, 0 AS Department, CONVERT(nvarchar(20),
dbo.invoices.invoiceDatePaid, 103) AS Cleared_Date, 'Bacs' AS Payment_type, dbo.invoices.invoiceId, dbo.invoices.invoiceTotal AS Value, '9' AS vat,
' ' AS bllank, 1 AS Ex_rate
FROM dbo.invoices INNER JOIN
dbo.companies ON dbo.invoices.invoiceCompanyId = dbo.companies.companyId
WHERE (dbo.invoices.invoiceDatePaid >= DATEDIFF(DAY, 1, CURRENT_TIMESTAMP)) AND (dbo.invoices.invoiceDatePaid < DATEDIFF(DAY, 0,
CURRENT_TIMESTAMP)) AND (dbo.companies.companyPaymentType = 3)
ORDER BY dbo.invoices.invoiceId DESC
在Payment_Type列中,我想将Value列的SUM添加到单词'Bacs'中,因此它将'Bacs£sum'读为2位小数。您能否提供所有已提供的帮助和建议,请帮助,问候和感谢
答案 0 :(得分:0)
我对你究竟需要什么并不十分清楚。您需要显示整个列的完整总和或以组方式显示,但这里是您可以尝试的...在将其转换为varchar之后添加sum(Value),这是必要的,因为两个数据类型必须是varchar才能使用和所有剩余的列分组......像这样的东西
...
, '巴奇' +铸造(总和(dbo.invoices.invoiceTotal) as varchar)AS Payment_type
...
按剩余的所有列进行分组
...
按条款订购
我不知道它是否接近你需要的东西,但它只是一个尝试帮助: - )