Click here to Skip to main content
15,890,690 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have data like :

IPO_No Item_No Line_Item_Seq_No Release_No
15063 11104 1 1
15063 11104 1 1
15063 11104 1 1


so i want release no will display like 1,2,3...not 1,1,1.
Please help me
Posted
Comments
DamithSL 28-Apr-14 6:53am    
can't you set IPO_No,Item_No,Line_Item_Seq_No and Release_No as composite primary key? then you will get exception when you try to insert same value. in case of exception you can increase the Release_No and try again until success.
Member 10685464 28-Apr-14 7:07am    
actaully po_no,Item_no,line_item_seq_no are from po_master and po_item table respectively

1 solution

Hello,

Please try below query and let me know if it helps your need.

SQL
with ctetest  (IPO_No,Item_No   ,Line_Item_Seq_No  ,Release_No) as
(
select 15063    AS IPO_No, 11104    as Item_No  ,1 as   Line_Item_Seq_No  ,1 as Release_No
union all
select 15063    AS IPO_No, 11104    as Item_No  ,1 as   Line_Item_Seq_No  ,1 as Release_No
union all
select 15063    AS IPO_No, 11104    as Item_No  ,1 as   Line_Item_Seq_No  ,1 as Release_No
)

select IPO_No,Item_No,Line_Item_Seq_No,ROW_NUMBER() over (order by IPO_No asc) Release_No from ctetest


Thanks,
Hitesh Varde
 
Share this answer
 

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