Saturday, June 29, 2013

NonExist Join

static void Job7(Args _args)
{
    container ret;
    container data;
    CustTable custTable;
    InventBuyerGroupList groupList;
    InventBuyerGroup inventBuyerGroup;
    while select custTable
        notExists join firstOnly groupList
        where groupList.CustAccount == custTable.AccountNum
        join inventBuyerGroup
        where
         groupList.GroupId == InventBuyerGroup.Group
    {
       
        data = [custTable.AccountNum,
        custTable.AccountNum,
        custTable.name()];
        ret = conIns(ret, conLen(ret)+1, data);      
    }
}

select custTable
        notExists join firstOnly groupList
        where groupList.CustAccount == custTable.AccountNum
select all customers whose account number does not exist in GroupList(InventBuyerGroupList ).

No comments:

Post a Comment