Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SELECT *,
- --primary_id, Первого повавшегося значения в данном случае по order by
- json_agg(email) over (PARTITION BY phone) as count_phone,
- count(phone) over (PARTITION BY phone) as count_phone
- FROM client
- left join customer c on client.id = c.client_id
- left join "order" o on c.id = o.customer_id
- where phone = '123456'
- order by o.date_added
Advertisement
Add Comment
Please, Sign In to add comment