Link to home
Start Free TrialLog in
Avatar of kungfunavs
kungfunavs

asked on

sum of transactions plus number of transactions

Hi,

i have a query where it gives me the sum of all the transactions in a given time period, i need to now add the number of transactions to this query, i have no idea on how to tackle this and would like some pointers in the right direction, my SQL knowledge is quite basic.

we are using MS SQL server 2000.
Avatar of lcohan
lcohan
Flag of Canada image

You mean something like this? To get the relative record number in a record set?

SELECT id, (SELECT COUNT(*) FROM table_name t2 WHERE t2.id <= t.id) AS rownumber
FROM table_name t
ORDER BY id
Can you post your query?
ASKER CERTIFIED SOLUTION
Avatar of Scott Pletcher
Scott Pletcher
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of kungfunavs
kungfunavs

ASKER

Hi, sorry for the delay i was out of office,

how would i use count if my select sum is like this

SELECT     dbo.tblDonationAllocations.DonationType, dbo.tblDonationAllocations.DonationDetails, SUM(CASE Currency WHEN '£' THEN Amount ELSE 0 END)
                      AS [£], SUM(CASE Currency WHEN '$' THEN Amount ELSE 0 END) AS [$], SUM(CASE Currency WHEN '€' THEN Amount ELSE 0 END) AS [€]
Maybe:


SUM(CASE Currency WHEN '£' THEN 1 ELSE 0 END) AS [£ Count],
SUM(CASE Currency WHEN '$' THEN 1 ELSE 0 END) AS [$ Count],
SUM(CASE Currency WHEN '€' THEN 1 ELSE 0 END) AS [€ Count]