## Sum of cash and cheque from a table

how to write a check for cash withdrawal
can you write a check to yourself to get cash?
how to write a check for cash for someone else
can you cash a check made out to cash
check made out to cash traceable
can you write a check to yourself with no money
i found a check made out to cash
how to cash a check for cash

I need to get the sum of cash and cheque amount from a table in 2 columns order by salesman.

My table is like this:

```Salesman A  Cash    21151
Salesman B  Cash    34510
Salesman C  Cash    21252
Salesman D  Cash    13356
Salesman A  Cheque  13944
Salesman B  Cheque  87368
Salesman C  Cheque  20182
Salesman D  Cheque  23862
```

SQL:

```SELECT Ca.Cash,  Cr.Credit FROM
(SELECT Salesman, PayMode, SUM(Collection) AS Cash
FROM Prospect_Detail WHERE(Purpose = 'Collections') AND (PayMode = 'Cash')
GROUP BY Salesman, PayMode) AS Ca
CROSS JOIN
(SELECT Salesman, PayMode, SUM(Collection) AS Credit
FROM Prospect_Detail WHERE(Purpose = 'Collections') AND (PayMode = 'cheque')
GROUP BY Salesman, PayMode) Cr
```

And I need to get the result like this:

```Salesman       Cash      Cheque
Salesman A     21151     13944
Salesman B     34510     87368
Salesman C     21252     20182
Salesman D     13356     23862
```

You can pivot your table on the following way

```With c as(
SELECT Salesman
, Paymode
, Sum(Collection) AS Cheque
FROM
Prospect_Detail
GROUP BY
Salesman
, Paymode
)
Select Salesman
,[Cash]
,[Cheque]
From C
Pivot(
Sum(Cheque)
For Paymode in ([Cash],[Cheque])
) as pvt;
```

I hope this works for you.

SQL: How to to SUM two values from different tables, select region,sum(number) total from ( select region,number from cash_table union all select region,number from cheque_table ) t group by region payments table with: CountryId (FK to countries), Total, Type (cash/cheque). i need to get the sum of cash and cheque amount from a table in 2 columns order by salesman my table is like this Salesman A Cash 21151.75 Salesman B Cash 34510.51 Salesman C Cash 21252 Salesman D Cash 13356 Salesman A Cheque 13944 Salesman B Cheque 87368.5 Salesman C Cheque 20182 Salesman D Cash 23862.05

You can try the following.

```create table #Temp (name varchar(50), collectionType varchar(10), amount int)
insert into #Temp values
('Salesman A', 'Cash', 21151),
('Salesman B', 'Cash', 34510),
('Salesman C', 'Cash', 21252),
('Salesman D', 'Cash', 13356),
('Salesman A', 'Cheque', 13944),
('Salesman B', 'Cheque', 87368),
('Salesman C', 'Cheque', 20182),
('Salesman D', 'Cheque', 23862)

SELECT name, Cash, cheque
FROM
(SELECT collectionType, name , amount
FROM #Temp) AS SourceTable
PIVOT
(
SUM(amount)
FOR collectionType IN ( Cash ,  Cheque)
) AS PivotTable;
```

The output is as shown below

```name        Cash    cheque
--------------------------
Salesman A  21151   13944
Salesman B  34510   87368
Salesman C  21252   20182
Salesman D  13356   23862
```

You can find the live demo Here.

[Solved] Sum of cash and cheque from a table, Have a look at the pivot clause. Simple Way To Use Pivot In SQL Query[^] SQL Server: PIVOT Clause[^]. I have a number of tables with values I need to sum up. They are not linked either, but the order is the same across all the tables. Basically, I would like to take this two tables: CASH TABLE London 540 France 240 Belgium 340 CHEQUE TABLE London 780 France 490 Belgium 230 To get an output like this to feed into a graphing application:

Suggestions to pivot are a VAST over-complication for this. Ignore them. Just use conditional summation. A simplified example:

```select Salesman, sum(case Paymode when 'Cash' then Collection else 0 end) as Cash, ...
from Prospect_Detail
where Purpose = 'Collections'
group by Salesman
order by Salesman;
```

Sum of cash and cheque from a table, 问题: I need to get the sum of cash and cheque amount from a table in 2 columns order by salesman. My table is like this: Salesman A Cash� One of the scenarios at work has left me with a number of tables with values I need to sum up. They are not linked either, but the order is the same across all the tables. Basically, I would like to take this two tables: CASH TABLE London 540 France 240 Belgium 340 CHEQUE TABLE London 780 France 490 Belgium 230

It is possible to use `PIVOT` operator to get the desired result:

```DECLARE @tbl TABLE
(
SalesMan varchar(50),
PayType VARCHAR(10),
Amount INT
)

INSERT INTO @tbl
(
SalesMan,
PayType,
Amount
)
VALUES
('Salesman A', 'Cash',  21151)
, ('Salesman B', 'Cash',    34510)
, ('Salesman C', 'Cash',    21252)
, ('Salesman D', 'Cash',    13356)
, ('Salesman A', 'Cheque',  13944)
, ('Salesman B', 'Cheque',  87368)
, ('Salesman C', 'Cheque',  20182)
, ('Salesman D', 'Cheque',  23862)

SELECT *
FROM
(
SELECT * FROM @tbl
)AS FooData
PIVOT(
AVG(FooData.Amount)
FOR PayType IN ([Cash], [Cheque])
) AS FooPivot
```

Ouptut:

```SalesMan    Cash    Cheque
Salesman A  21151   13944
Salesman B  34510   87368
Salesman C  21252   20182
Salesman D  13356   23862
```

Accounting for Cash Transactions, Total deposits in transit added incorrectly. Double check your addition of deposits in transit. Bank balance transposed. Did you start with the correct amount at the� The SUM() Function adds numeric column values together and returns the result. It’s very easy to use it on one table: SELECT SUM(<column>) FROM <table>;; However

How to Write and Cash Checks Payable to Cash, When you write a check, you don't always have to specify who gets the money. A check that says "Pay to the Order of: Cash" can be cashed or deposited by� When you get paid with a check, there are two ways to get access to the money behind the check: You can either cash the check or deposit it. In the process of negotiating that check, you’ll want to keep fees to a minimum and avoid expensive mistakes.

• I don't see that `PIVOT` is any more or less complicated than this. Swings and roundabouts for me really