title: How to add or update data on row but will not duplicate item with the same row that has two same value
body: <p><a href="https://i.stack.imgur.com/Krn3s.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Krn3s.png" alt="enter image description here" /></a></p>
  <p>I would like to ask for help in my sql command where I would add or update a group. Where as having conditions.</p>
  <ol>
  <li>Group can only have 3 different type.</li>
  <li>Person can change his type or group name if the type on that group is not yet used</li>
  <li>New person is added if he or she is not yet existing on the table but will not be added if he or she selected a type on a group which is already used.</li>
  <li>New person is added if he or she create a new group.</li>
  </ol>
  <p>What I am having trouble is on how to check if the type on a group is already in used. I have added my query below.</p>
  <p>Please if you have questions or corrections I am happy to address. Thank you!</p>
  <pre class="lang-none prettyprint-override"><code>ID     Type    GroupName    Name
  -------------------------------
  00      1        GROUPA     John
  01      2        GROUPA     Jane
  02      3        GROUPA     Ted
  03      1        GROUPB     Rose
  04      2        GROUPB     Eric
  05      3        GROUPB     Nico
  </code></pre>
  <pre class="lang-sql prettyprint-override"><code>    IF NOT EXISTS(SELECT * FROM TABLEA as ATG WHERE @ID = ATG.ID)
              BEGIN
                  INSERT INTO TABLEA(ID,TYPE,GroupName,Name)
                  VALUES (@ID,@TYPE,@GroupName,@Name)
              END
      ELSE
              BEGIN
                  UPDATE TABLEA SET [ID] = @ID,[TYPE] = @TYPE ,[GroupName]=@GroupName, [Name]= @Name
                  WHERE ID = @ID
              END
  </code></pre>