• Arggh Sean you beat me to it lol, anyhoo here is my attempt:

    with SCC_CTE(VENDID, VENDTYPE)

    as (select 'ABC', 1 union all

    select 'ABC', 0 union all

    select 'ABC', 0 union all

    select 'XYZ', 1 union all

    select 'XYZ', 0 union all

    select 'XYZ', 0 union all

    select 'XYZ', 0)

    select vendid,vendtype,

    case when vendtype = 1 then vendid else VENDID + '-' + right('0'+theRank, 3) end

    from (

    select VENDID, VENDTYPE, cast(row_number() OVER (PARTITION BY VENDID, VENDTYPE ORDER BY VENDID) as varchar) as theRank

    from scc_cte) as a

    ---------------------------------------------------------

    It takes a minimal capacity for rational thought to see that the corporate 'free press' is a structurally irrational and biased, and extremely violent, system of elite propaganda.
    David Edwards - Media lens[/url]

    Society has varying and conflicting interests; what is called objectivity is the disguise of one of these interests - that of neutrality. But neutrality is a fiction in an unneutral world. There are victims, there are executioners, and there are bystanders... and the 'objectivity' of the bystander calls for inaction while other heads fall.
    Howard Zinn