title: Create a flag value based on the duplicate values on one column in SQL
body: <p>I am quite new to SQL. Playing around with it and got stuck in the following scenario.</p>
  
  <p>I have a table with the following data</p>
  
  <p><a href="https://i.stack.imgur.com/vwtVj.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vwtVj.png" alt="enter image description here"></a></p>
  
  <p>My requirement is, in the FirstCol column, it has '11121' 3 times, and SecondCol has 1001 two times against FirstCol and it has 1002 against the same '11121' value which should not be. If it exists that way, I need to find all the data in such scenarios and need to display a column beside these two columns with a flag value indicating 1 if the value in the SecondCol is different than the other values. '0' should be displayed for the remaining.</p>
  
  <p>I tried using group by, dense_rank() but couldn't get the desired results. Someone please help me out in getting the desired result for this.</p>