Click here to Skip to main content
15,118,573 members
Please Sign up or sign in to vote.
4.00/5 (2 votes)
See more:
I have simple query below is the code:
HTML
"Ag Silver I  0.80 0 Negative
Ag  Silver II 1.08 0 Negative "
i just want to remove the "Ag" which is coming twice from the inner join so i just want to show serial no and "Ag" name unique if datalist contain multiple time .

I would like this :
HTML
"1. Ag Silver I  0.80 0 Negative
    Silver II 1.08 0 Negative "

Hope my query is not getting complex
Thanks
Posted
Updated 31-Jan-12 5:44am
v2
Comments
Herman<T>.Instance 31-Jan-12 10:43am
   
you can use Row_Number() function.
Show your query and I help you out!

1 solution

an example:
SQL
SELECT case when t.rowno=1 then CompanyName else null end as CompanyName, Product, Price, NrOrdered, Status
    FROM
        (
            SELECT Row_Number() over (partition by CompanyName order by CompanyName ) as rowno
            , CompanyName, Product, Price, NrOrdered, Status
FROM    YourTable
        ) as t
   
Comments
sharad_sharma82 2-Feb-12 1:38am
   
i have done this and its work fine can i also show the numbering as same .
sharad_sharma82 2-Feb-12 2:08am
   
I want numbering in this order:
"1. Ag Silver I 0.80 0 Negative
Silver II 1.08 0 Negative
2. SU Silver I 0.80 0 Negative
Silver II 1.08 0 Negative "
but working like this :
"1. Ag Silver I 0.80 0 Negative
2 Silver II 1.08 0 Negative
3. SU Silver I 0.80 0 Negative
4 Silver II 1.08 0 Negative "
Thanks for help

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900