Mysql query relating to count and date time -


i have table 'transaction' contains columns transaction_id, sender_id,amount, date_time,payee_id . want find transactions more 5 made sender_id in 1 day single sender. tried mysql> select * transaction sender_id count() =5 , datedif() =1;

i think query helpful you.

select sender_id, count(sender_id) count   `transaction` group sender_id, date(date_time) having count>5 

this return list of sender_ids have more 5 transactions if need list of transactions need this

select t.* ( select sender_id, count(sender_id) count   `transaction` group sender_id, date(date_time) having count>5 ) senders inner join `transaction` t on t.sender_id=senders.sender_id 

ps. performance recommend run second query on mysql server version 5.6.10 or higher


Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -