Skip to content
Advertisement

Tag: datetime

Making cumulative sum with ids and dates in MySQL

Imagine I have this: id transactiondate transactiontag clientid transactionvalue 1 2020-12-28 pizza 0 29.99 2 2020-12-29 payment 0 -39.99 3 2020-12-28 cheese 0 -109.99 4 2020-12-28 cheese 0 -109.99 5 2020-12-28 pizza 1 -19.99 6 2020-12-28 cheese 1 -18.99 7 2020-12-28 salary 1 58.99 8 2020-12-29 salary 1 38.99 So I have all the Ids of transactions, when they were

Combine two different rows in single table using same table in SQL Server

Consider a database table holding data like that: Id UserId IsCheckIn DateTime Image AccountId 30356 60866 1 2020-12-19 12:17:17 b622f3e0806f.jpg 10017 30355 60866 0 2020-12-19 10:52:26 b622f3e0806f.jpg 10017 30354 60866 1 2020-12-19 10:51:02 b622f3e0806f.jpg 10017 30353 60866 0 2020-01-20 09:29:42 1596.jpg 10017 Desired output : Id UserId IsCheckIn InDateTime InImage AccountId IsCheckOut OutDateTime OutImage 30356 60866 1 2020-12-19 12:17:17 b622f3e0806f.jpg

sql get balance at end of year

I have a transactions table for a single year with the amount indicating the debit transaction if the value is negative or credit transaction values are positive. Now in a given month if the number of debit records is less than 3 or if the sum of debits for a month is less than 100 then I want to charge

Advertisement