Q:

SQL Pivot Group by?

I got a working pivot table but I wanted to know if there's a way to group by the pivot table. For the pivot table code I have...
SELECT *  FROM 
    (SELECT  
          UserPivot.[parties]
          ,UserPivot.[Accounts]
          ,UserPivot.[CurrentAmount] 
          ,UserPivot.[Plus / Negative]
          FROM UserPivot) AS BaseData

PIVOT(
    SUM(BaseData.[CurrentAmount])
    FOR BaseData.[parties]
    IN([Toms])
) AS PivotTable

Once this is run, I get...
Accounts | Plus / negative | Toms
Bank             plus         100
Bank           negative        60

And above is correct and I need the [plus / negative] column to show all actions that are happening with a user! but I would to add a group by to show the total sum of an account and group them by different account types as well, for example I want this following result...
   Accounts  | Toms
    Bank        40

It's important that this is done through the pivot table as well. 
Thank you for the suggestions everyone!

A:

If you make the amount negative or positive in the source query, the SUM will use it.

SELECT *  
FROM 
(
  SELECT [Accounts],
  [parties],
  IIF([Plus / Negative] = 'negative', -[CurrentAmount], [CurrentAmount]) AS [CurrentAmount]
  FROM UserPivot
  WHERE [parties] IN ('Toms') -- This WHERE clause is just something that could increase performance of the query
) AS BaseData
PIVOT(
    SUM([CurrentAmount]) 
    FOR [parties]
    IN([Toms])
) AS PivotTable;

And if you don't want to hard code all the parties.
You could use a dynamic SQL for that.

declare @Cols nvarchar(1000); -- A list of the columns for the pivot
select @Cols = concat(@Cols+',', quotename([parties])) from UserPivot group by [parties];

declare @DynSql nvarchar(2000) = 'SELECT *  
FROM 
(
  SELECT [Accounts],
  [parties],
  IIF([Plus / Negative] = ''negative'', -[CurrentAmount], [CurrentAmount]) AS [CurrentAmount]
  FROM UserPivot
) AS BaseData
PIVOT(
    SUM([CurrentAmount]) 
    FOR [parties]
    IN('+ @Cols +')
) AS PivotTable';

EXECUTE sp_executesql @DynSql;

A test for both can be found here on RexTester.

