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.
Author |
Topic |
koushik
Starting Member
11 Posts |
Posted - 2010-10-12 : 02:43:35
|
Hi,I have a dataset like below :Tgt_Tbl_Col | Src_Tbl_Col | Level----------------|----------------------------------|----------L3_TAB1.COL1 | L2_TAB1.COL3 | 0L3_TAB1.COL2 | L2_TAB2.COL2 | 0L3_TAB1.COL3 | L2_TAB2.COL3 | 0L3_TAB1.COL4 | L2_TAB2.COL1 | 0L2_TAB2.COL1 | L1_TAB2.COL1 | 1L1_TAB2.COL1 | Source_Feed2.DATACOL1 | 2L2_TAB2.COL3 | L1_TAB3.COL3 | 1L1_TAB3.COL3 | Source_Feed3.DATACOL3 | 2L2_TAB2.COL2 | L1_TAB1.COL2 | 1L2_TAB2.COL2 | L1_TAB2.COL2 | 1L2_TAB2.COL2 | L1_TAB3.COL2 | 1L1_TAB3.COL2 | Source_Feed3.DATACOL2 | 2L1_TAB2.COL2 | Source_Feed2.DATACOL2 | 2L1_TAB1.COL2 | Source_Feed1.DATACOL2 | 2L2_TAB1.COL3 | L1_TAB1.COL1 | 1L2_TAB1.COL3 | L1_TAB3.COL1 | 1L1_TAB3.COL1 | Source_Feed3.DATACOL1 | 2L1_TAB1.COL1 | Source_Feed1.DATACOL1 | 2And I want the output in the format like below :Fina_Table | level1 | level2 | level3-----------|------------|------------|-----------L3_TAB1_01 | L2_TAB1_03 | L1_TAB1_01 | Feed1_01L3_TAB1_01 | L2_TAB1_03 | L1_TAB3_01 | Feed3_01L3_TAB1_02 | L2_TAB2_02 | L1_TAB1_02 | Feed1_02L3_TAB1_02 | L2_TAB2_02 | L1_TAB2_02 | Feed2_02L3_TAB1_02 | L2_TAB2_02 | L1_TAB3_02 | Feed3_02L3_TAB1_03 | L2_TAB2_03 | L1_TAB3_03 | Feed3_03L3_TAB1_04 | L2_TAB2_01 | L1_TAB2_01 | Feed2_01Can you please help me to get it in the best possible way.Actually this is a sample data I have prepared. In actual scenario table names might not start or end with any specific key word like L1 or L3 etc. Also the level here is clearly 3 but in actual scenario I will not be aware of the level at the beginning. It can be anything 7,8,12,90 .. anything.Regards,Koushik Chandra |
|
jcelko
Esteemed SQL Purist
547 Posts |
Posted - 2010-10-12 : 12:01:39
|
Please post DDL, so that people do not have to guess what the keys, constraints, Declarative Referential Integrity, data types, etc. in your schema are. Please learn to follow ISO-11179 data element naming conventions and formatting rules. Temporal data should use ISO-8601 formats. Code should be in Standard SQL as much as possible and not local dialect. Sample data is also a good idea, along with clear specifications. It is very hard to debug code when you do not let us see it. If you want to learn how to ask a question on a Newsgroup, look at: http://www.catb.org/~esr/faqs/smart-questions.html --CELKO--Books in Celko Series for Morgan-Kaufmann PublishingAnalytics and OLAP in SQLData and Databases: Concepts in Practice Data, Measurements and Standards in SQLSQL for SmartiesSQL Programming Style SQL Puzzles and Answers Thinking in SetsTrees and Hierarchies in SQL |
 |
|
|
|
|
|
|