select u_id,p_id,c_id from you_table
order by u_id, p_idSELECT u_id, c_id, COUNT(p_id) as 'count'
FROM you_table
GROUP BY p_id, c_id, u_id
ORDER BY count desc Get-User -OrganizationalUnit "IT" -RecipientTypeDetails User -Filter { UserPrincipalName -ne $Null } | Enable-MailboxGet-User -OrganizationalUnit "IT" -RecipientTypeDetails User -Filter { UserPrincipalName -ne $Null } | %{$forwardedEmail = "{0}@bleble.ru" -f $_.SamAccountName; Set-Mailbox -ForwardingAddress $forwardedEmail}