473,397 Members | 2,116 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Grouped rows inserted into columns

1
I need to INSERT rows from #temp table into #final table with grp_code and bap_id combination. Thanks.



Create Table #tmp (
sort_id int default 0,
grp_Code int default 1,
business_activity_profile_id INT,
business_activity_product_id int default 0,
value1_tx varchar(500) default NULL,
value2_tx varchar(500) default NULL
)


Data in the #temp table:

Sort_id grp_code bap_id Value1_tx Value2_tx

1 1 1 Alabama NULL
1 1 1 Alaska NULL
1 1 1 Arizona NULL
1 1 1 California NULL
2 1 2 Alaska NULL
2 1 2 Arizona NULL
2 1 2 Arkansas NULL
2 1 2 California NULL
3 1 3 Alaska NULL
3 1 3 Arizona NULL
3 1 3 Arkansas NULL
1 2 1 ACS Image Solutions NULL
1 2 1 ABC Virtual Communications, Inc NULL
1 2 1 ACS Unclaimed Propery Clearinghouse, Inc. NULL
1 2 1 ABC Virtual Communications, Inc NULL
1 2 1 ABC Virtual Communications, Inc NULL
1 2 1 Acxiom NULL
1 2 1 ABC Virtual Communications, Inc NULL
2 2 2 ABC Virtual Communications, Inc NULL
2 2 2 ACS Unclaimed Propery Clearinghouse, Inc. NULL
2 2 2 #NAME? NULL
2 2 2 ACS Image Solutions NULL
2 2 2 Acxiom NULL
2 2 2 ADP NULL
2 2 2 ADP Investor Communication NULL
2 2 2 Bancomer Transfer Services NULL
3 2 3 ABC Virtual Communications, Inc NULL
3 2 3 ACS Image Solutions NULL
3 2 3 ACS Unclaimed Propery Clearinghouse, Inc. NULL
3 2 3 Acxiom NULL
3 2 3 ABC Virtual Communications, Inc NULL
3 2 3 ACS Image Solutions NULL
35 3 47 STATE AND LOCAL LAWS AND REGULATIONS Insurance Laws & Regulations - Various States
35 3 47 STATE AND LOCAL LAWS AND REGULATIONS Escheat Laws
35 3 47 STATE AND LOCAL LAWS AND REGULATIONS State Credit Law Requirements
35 3 47 STATE AND LOCAL LAWS AND REGULATIONS State Deceptive Practices Laws
35 3 47 OTHER FEDERAL LAWS AND REGULATIONS American's with Disability Act Public Law 101-336 - Abstract
35 3 47 OTHER FEDERAL LAWS AND REGULATIONS Bankruptcy Laws
35 3 47 OTHER FEDERAL LAWS AND REGULATIONS COBRA
35 3 47 OTHER FEDERAL LAWS AND REGULATIONS Department of Labor Rules




Create Table #final (
sort_id INT,
bap_id INT,
geography varchar(120) NULL,
vendor_nm varchar(250) NULL,
regulator varchar(100) NULL,
regulation varchar(500) NULL
)



This is how it needs to be inserted into #final table:

rows from value1_tx inserted into Column 'geography' WHERE grp_code =1 and bap_id = 1
rows from value1_tx inserted into Column 'vendor_nm' WHERE grp_code =2 and bap_id = 1
rows from value1_tx inserted into Column 'regulator'WHERE grp_code =3 and bap_id = 1
rows from value2_tx inserted into Column 'regulation' WHERE grp_code =3 and bap_id = 1
Oct 24 '06 #1
0 1446

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Marko Poutiainen | last post by:
Situation: We had to make our SQLServer 2000 database multi-lingual. That is, certain things (such as product names) in the database should be shown in the language the user is using (Finnish,...
3
by: Jim Heavey | last post by:
Trying to figure out the technique which should be used to add rows to a datagrid. I am thinking that I would want an "Add" button on the footer, but I am not quite sure how to do that. Is that...
68
by: Martin Joergensen | last post by:
Hi, I have some files which has the following content: 0 0 0 0 0 0 0 1 1 1 1 0 0 1 1 1 1 0 0 1 1 1 1 0 0 1 1 1 1 0 0 0 0 0 0 0
1
by: ericjb | last post by:
I have a table with many columns in it. Each row has an ORDER_ID, ORDER_LINE_ID, START_DATE, and END_DATE. The combination of said columns make the row unique. Currently, the row has a start date...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.