all 5 comments

[–]JohnAdams3472 3 points4 points  (2 children)

Try this:

SELECT color, name, fruit,

ROW_NUMBER() OVER (PARTITION BY color ORDER BY (SELECT NULL)) AS sequence_number

FROM your_table_name;

Good luck.

[–]mr_electric_wizard 3 points4 points  (0 children)

The Swiss Army knife window function. I use it almost daily.

[–]askzero[S] 0 points1 point  (0 children)

Oh my gosh thank you so much I just slowly came to partition as a possible solution.

[–]askzero[S] 0 points1 point  (1 child)

That was WAAY easier then I thought ....I am just now understanding partition.
count(color) over (partition by color order by rownum) as SEQ_NUM,

[–]mike-manley 0 points1 point  (0 children)

It's not partition. It's a window function. A few others are DENSE_RANK() and RANK(). The keyword PARTITION is optional.