sql server 2008 - Select multiple values from different rows on table_a into one new row on table_b -


i have table below:

'table_a' type | value -----+------------ 000  | 100020003 001  | 004 002  | 5000600070008 

i need end result set below:

'table_b'   ---+---+---+---  1 | 2 | 3 | 4     etc... 

i have used substring pull 1, 2, , 3 type = 000. need same type 001 , 002 how can joined create 1 row in 'table_b'?

so far have used below populate 1, 2 , 3 have no idea how select data remaining rows.

select substring(value,1,1) val_1        substring(value,5,1) val_2        substring(value,9,1) val_3   table_a  type = 000 

next query this: select substring(value,3,1) val_4 table_a type = 001

so can see cannot use union because not selecting same number of items in each select statement.

the data pulling not uniform conveys need correctly. appreciate assistance.

select substring(value,1,1) || "val_1",        substring(value,5,1) || "val_2",        substring(value,9,1) || "val_3",   table_a  type = 000 

Comments

Popular posts from this blog

authentication - Mongodb revoke acccess to connect test database -

r - Update two sets of radiobuttons reactively - shiny -

ios - Realm over CoreData should I use NSFetchedResultController or a Dictionary? -