Write a SQL query to retrieve and aggregate user activity data while making specific formatting alterations in the output layer.