is there some way who to get last record using rownumber() and SUM of one field (money in this case)? I've tried to come up with a query like:
SELECT
[date]
,...
FROM
(
SELECT
CAST(t.timestamp AS DATE) AS [date]
,.../some fields/
,row_number() over (partition by ca.logical_number order by t.timestamp DESC) as rownumber --last update(record) transaction
--,amount_transferred =
--(
-- SELECT
-- ,SUM(t.money_value) AS amount_transferred
-- FROM
-- TO_Transaction t
-- GROUP BY
-- CAST(t.timestamp AS Date)
--)
) AS t
WHERE rownumber=1
What the query is supposed to do is to find current purse balance and all money transferred during a day. Any help would be aprreciated. Thanks.