Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 How to merge table

Author  Topic 

juicyapple
Posting Yak Master

176 Posts

Posted - 2008-05-31 : 03:07:45
Hi, I have 4 tables,

create tbl_Header (Rec_ID int)
create tbl_Header_Details (Rec_ID int, type_id int, desc varchar(20))
create tbl_type (type_id int)
create tbl_series (type_id int, series_id int)

tbl_Header links to header details by Rec_ID, which is 1 to many
tbl_Header_Details link to tbl_type by type_id, which is 1 to many tbl_type link to tbl_series by type_id, which is 1 to many


how to merge these tables to create a tmp table with only distinct record on rec_id, and generate new column based on the number of series_id it has. Rec_id should not have repeated.

Please help!

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-05-31 : 07:57:09
What are should be columns retrieved? What should be rule for retrieving values when taking distinct of rec_id? As the relationship is 1 to many you will have more than 1 values for other fields for each rec_id. Do you need to retrive max,min or random value? Sample data to illustrate it will be great.
Go to Top of Page
   

- Advertisement -