Group by alternative
If I understand you correctly, try this:

with ActionX as (
   select
        ActionID, coalesce(LoginID,'_')) as LoginID, ActionCode
    from ActionTable
)
select
    a.ActionID,
    a.LoginID
    b.ActionCode
from (
   select
        ActionID, max(LoginID) as LoginID
    from ActionX t
    group by ActionID
) a
join ActionX  b
   on b.ActionID  = a.ActionID
  and b.LoginID   = a.LoginID