You can use all the functions you mentioned, but not Set Analysis in the script. However, that you should not be worried about, because you can achieve your goal in the script without that. Try like:
Count(user_id) as user_count
from <> Group By user_id;
'Group By' is important when using any aggregation function in the script. Learn about it.
Yes, you can use all mentioned function at script level. As these function are aggregate function so you need to group them which you can do by Group By.
Set Analysis is used at front end not at script level, but yeah as tresesco mentioned their are alternates to achieve your goal with the same output as it is done by Set Analysis at UI level, same you can achieve at script level too.