-2
select ID_Sale,SaleDate,Branch_Name,P_Name,P_UnitPrice,QuantitySold,
sum (QuantitySold*P_UnitPrice) over (order by ID_Sale asc) AS RunningTotal
from tblP_Sales
INNER JOIN tblProduct_With_Img
ON tblP_Sales.P_ID_Sales = tblProduct_With_Img.P_ID
INNER JOIN tblBranches
ON tblP_Sales.BranchID = tblBranches.BranchID
--this group is not working ? how to work this ?
group by P_Name
這是沒有GROUP BY
條款的結果:我認爲你正在尋找增加 「PARTITION BY」如何按名稱對我的查詢進行分組? P_Name
Sale_ID Sale_Date Branch Item Name Pric/unit qty RUNTotal
1056 2016-11-10 Ajman Afghani Pulaw With Meat 26 1 26
1057 2016-11-10 Ajman Sada Rice With Chicken Boti 24 2 74
1058 2016-11-11 Ajman Afghani Pulaw With Meat 26 1 100
代碼唯一的問題是很難回答。請看看http://stackoverflow.com/help/how-to-ask – HoneyBadger
請再解釋一下你的問題。你指的是哪個'名字'('Branch_Name','P_Name',還有別的東西)?請儘可能提供示例數據。 – sr28
相同的查詢只是由P_Name(Product_Name) –