Question: I was doing some python and noticed that:

```
print(len(str(int))

```

yields 13.
To be clear, int is just the integer class, no variable assigned to it. You could run just this code and it yields 13.
Now that I think about it, could it be printing the length of 'string' and 'integer' together? If so, why?

Answer: 
You seem to want to mark the first occurrence as unique, but not others. So, let's join in the comparison value:

```
select t.*,
       (id = min_id) as is_first_occurrence
from t join
     (select customer_id, min(id) as min_id
      from t
      group by customer_id
     ) tt
     on t.customer_id = tt.customer_id;

```

For most people, a "unique" flag would mean that the overall count is "1", not that this is merely the first appearance. If that is what you want, then you can use similar logic:

```
select t.*,
       (id = min_id) as is_first_occurrence,
       (cnt = 1) as is_unique
from t join
     (select customer_id, min(id) as min_id, count(*) as cnt
      from t
      group by customer_id
     ) tt
     on t.customer_id = tt.customer_id;

```

And, in MySQL 8+, you would use window functions:

```
select t.*,
       (row_number() over (partition by customer_id order by id) = 1) as is_first_occurrence,
       (count(*) over (partition by customer_id) = 1) as is_unique
from t;

```
You can try below

```
select id,a.customerid, case when cnt=1 then 1 else 0 end as Unique_Flag
from tablename a 
left join 
(select customerid, count(*) as cnt from tablename
group by customerid
)b on a.customerid=b.customerid

```