I need to find clients whose personal account balance is more than 100. Output client_id,balance, find clients who have more than 3 sim cards. Output name, number of sim cards, find customers whose birthday is next month. Output name, birth_date. I do not understand how these tasks can be done, I have tried many options. I am very grateful for the help
>Solution :
Here is one way:
select
c.*
from
clients c
left join accounts a on a.client_id = c.client_id
left join
(select account_id, count(*) cnt from sim_cards group by account_id) s
on s.account_id = a.account_id
where
s.cnt > 3
and a.balance > 100
