Group by alternative I have a table , that has a generic set of actions for EVERY user.

However if there is a user that needs to have a unique action, that replaces an existing action,  then in my query, I want to exclude the generic action.  

So for example every logged in user gets two actions OPEN or CLOSE based on the table below.

SELECT ActionID, ActionCode FROM Actions

ActionID,  ActionCode,      LoginID. 
OPEN       Open contract    NULL – Generic Open Operation
CLOSE      Close Contrct    NULL  -- Generic Close Operation


A new user has a very specific OPEN case so if I add a row to the Action table 

ActionID, ActionCode,    LoginID. 
OPEN      Open contract   NULL  – Generic Open Operation
CLOSE     Close Contrct   NULL  - Generic Close Operation
OPEN1     Open1 contract  123   – Specific Open Operation only to user logged in as 123


So then I perform the following query

SELECT ActionID, ActionCode FROM Actions WHERE (LoginID = 123 OR LoginID is null)


I get 

OPEN    Open contract   NULL    
CLOSE   Close Contrct   NULL    
OPEN1   Open1 contract  123     


But I want 

CLOSE   Close Contrct   NULL    
OPEN1   Open1 contract  123
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