Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Double each row, and then append a column 1

Status
Not open for further replies.

whatcom

Technical User
Aug 27, 2007
8
US
Hello

I have a sql table which has three columns. The combined columns work as the primary key. The table has data similar to:

No Case Code
111 ADM GAD
112 ADM TRM
113 BSP RLR

Essentially, what I would like to do is to double up every row, and then add a "B" and an "H" to the end of each duplicate row. So, I need to have the above table look something like:

No Case Code
111 ADM GADB
111 ADM GADH
112 ADM TRMB
112 ADM TRMH
113 BSP RLRB
113 BSP RLRH

Does anyone know the best way to do this?
 
SELECT No, Case, Code || 'B' FROM yourTable
UNION SELECT No, Case, Code || 'H' FROM yourTable

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks PHV.

That gave me a start. I wound up creating two separate tables. For the first table, I added a "h". For the second, I add a "b". Then, I created a new table, and did a "insert into" and unioned those two tables together.

Thanks for giving me a start on this.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top