Need a Query

  • Hi All!

    Can the following scenario be achieved?

    The following is the 2 columns value which is chained frm P1 - C1+R1 n P2 - R2,

    P1 - C3

    C3 - C2

    C2 - C1 + R1

    P2 - CH2

    CH2 - CH1

    CH1 - R2

    I need a query which ll display those as like below,

    P1 - C3

    P1 - C2

    P1 - C1

    P2 - CH2

    P2 - CH1

    Can any one help me with query?

  • Couldnt realy follow it.

    do you want to order by or some thing?

    not clear.

    is it a calculated col.

    if you send some details like create table and insert into commands and then say the result probaly some one will help you out.

    Regards
    Vinay

  • put more detail on your question so as that somebody can help you about your problem...

    try visiting this link --- http://www.sqlservercentral.com/articles/Best+Practices/61537/

  • If you are looking for SQL then the best way to put is :

    Input Sample Data and Output Sample Data and few lines about the requirement.

  • Ok Sorry for my xplanation

    Kindly assume T1, T2, T3 - Tables

    T1 |

    ----

    P1 |

    C3 |

    C2 |

    T2|

    ---

    C3 |

    C2 |

    C1 |

    R1 |

    T3

    ---

    Col1 - Col2

    P1 - C3

    C3 - C2

    C2 - C1

    C1 - R1

    All those values are linked as Chain in third Table T3 in 2 cols, but the start of the Chain is P1 which leads to C3 --> C2 --> C1 --> R1.

    So need to show tht P1 is the start for all those commencing values.

    Now, need a query which ll display those as like below,

    Col1-Col2

    P1 - C3

    P1 - C2

    P1 - C1

    P1 - R1

    Kindly help me to arrive at teh query... plz

    Thanks for ur Help!!

  • Hi

    This is similar to parent child relationship and finding out all the childerns of a parent using T3 table (where the Parent and Child relationship is mentioned).

    Check out the below link on Tree & hierarchical queries.

    http://www.sqlteam.com/article/more-trees-hierarchies-in-sql

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply