Question: I have a created one Field on contact which is having checkbox data type name as "In use".
I have a requirement like

1.One Contact can only be active at one place at a time. So we want to restrict the "In Use" field from being active if it is currently active on another Contact for the same account.

Answer: 
Can you try below trigger 

```
trigger validate on Contact(before insert){
    SET<String> ids = new SET<String>();
        for(contact c : trigger.new){
            ids.add(c.AccountId);
        } 
        List<AggregateResult> tempAggr = [SELECT AccountId acc FROM Contact WHERE inUse__c= true AND Accontid IN : ids GROUP BY AccountId];

        Set<String> inUseset = new Set<String>();
        for(AggregateResult rs : tempAggr){
            inUseSet.add(String.valueOf(rs.get('acc')));
        }

        for(contact c : trigger.new){
            if(inUseSet.contains(c.AccountId)){
                c.inUse__c = false;
            }
            else{
                c.inUse__c = true;
                inUseSet.add(c.AccountId);
            }
        }
    }

```
I hope this would be helpful... 

```
   trigger validate on Contact(before insert){

        set<id> rids = new set<id>();
        set<id> Uids = new set<id>();

        for(contact c : trigger.new){
              rids.add(c.AccountId);
        }
        list<contact> conts = [select accountid from contact where accountid IN :rids AND In_Use__c = true];
        for(contact c : conts){
           uids.add(c.accountid);
        }

        for(contact c : trigger.new){
             if(uids.contains(c.AccountId)){
                   c.addError('Account Related contact is already in Use');    
             }   

        } 
}

```