以下SQL查询没有对所有相同的项目进行分组,我附加了一个图像,让所有人都清楚。 [![在此处输入图像说明] [1]] [1]
在图像中,根据每个分支的货币应该是groupby,但它不是用相同的货币分组。
SELECT BR.BranchName BranchName,
PDS.ProductName Currency,
SUM( FCBSD.Quantity) Quantity,SUM(CONVERT(DECIMAL(12,3),
(FCBSD.Quantity*FCBSD.DealingRate))) LocalCurrency
,case when (FCBSD.IsBuy=0) then 'Sell' else 'Buy'end [Type],
SUM(SUM(CONVERT(DECIMAL(12, 3), FCBSD.Quantity*FCBSD.DealingRate))) OVER (PARTITION BY BR.BranchID) [TOAL]
FROM ALX_FCBuySell FCSB
LEFT JOIN ALX_FCBuySellDetails FCBSD ON FCSB.FCBuySellID= FCBSD.FCBuySellID
LEFT JOIN ALX_Branches BR ON FCSB.BranchID= BR.BranchID
LEFT JOIN ALX_Products PDS ON FCBSD.ProductID=PDS.ProductID
GROUP BY BR.BranchName, PDS.ProductName,BR.BranchID,FCBSD.Quantity,FCBSD.IsBuy
ORDER BY BR.BranchName
它是Exact out我需要每种货币应该是groupby下的groupby和每个分支 [![在此处输入图像说明] [2]] [2]
答案 0 :(得分:1)
#let's say copy or move a file from one dir to other dir
import os, sys
os.system('ssh user@Ip_of_worker-1 "cp directory_1/file1.csv directory_2"')
os.system('ssh user@Ip_of_worker-2 "cp directory_1/file1.csv directory_2"')
os.system('ssh user@Ip_of_worker-3 "cp directory_1/file1.csv directory_2"')
在您的代码中,您必须从组中删除FCBSD.Quantity。所以你应该根据类型和分支机构获得groupby形式的所有货币。试试这个并发表您的意见