2016-11-11 9 views
-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句なしの結果である:クエリを名前でグループ化するにはどうすればいいですか? 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 
+3

コードのみのご質問にはお答えすることは困難です。 http://stackoverflow.com/help/how-to-ask – HoneyBadger

+0

あなたの質問をもう少し説明してください。あなたは( 'Branch_Name'、 'P_Name'、その他)を参照していますか?可能であれば、例データを提供してください。 – sr28

+0

同じクエリをP_Name(製品名)でグループ化してください –

答えて

0

私はあなたが追加するために探していると思う

"PARTITIONをBY"
select ID_Sale,SaleDate,Branch_Name,P_Name,P_UnitPrice,QuantitySold, 
    sum (QuantitySold*P_UnitPrice) over (PARTITION BY P_Name 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 
+0

P_Nameのグループを作成します。P_Name(製品名)をグループ化します。 –

関連する問題