Need Help with Logic

  • Hi Friends,

    My possible result sets(o/p) from joining two tables are

    Possible o/p 1:

    c1 c2 c3

    1 1 a

    1 1 b

    Possible o/p 2:

    c1 c2 c3

    1 1 a

    1 2 a

    1 1 b

    1 2 b

    *c1, c2,c3 are Column1,column 2, column3

    My Question is without using a Temp table or table varible etc. Can we get the result as follows:

    Possible o/p 1:

    c1 c2 c3

    1 1 a

    1 1 b

    Possible o/p 2:

    c1 c2 c3

    1 2 a

    1 2 b

    Please Some one help with the Logic.

    Thanks in Advance.

  • My possible result sets(o/p) from joining two tables are

    Possible o/p 1:

    col1 col2 col3

    1 1 a

    1 1 b

    Possible o/p 2:

    col1 col2 col3

    1 1 a

    1 2 a

    1 1 b

    1 2 b

    .... without using a Temp table or table varible...

    Homework problem?

    Seriously: Are the sample tables you posted intended to be the source tables from which you want desired results, or are they the result of two different joins for which you neglected to show us the code?

    Please post sample schema and source data for the two tables, and we'll try to give you the result you're asking for. Thanks.

    __________________________________________________

    Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
    Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills

  • select * from [Possible o/p 1]

    and

    select * from [Possible o/p 2]

    where c2 = 2

    will get you exactly what you are asking.

    😀

    To paraphrase Dixie, you have not provided enough information.

    Please include create table statements and insert statements to load up your tables.

Viewing 3 posts - 1 through 2 (of 2 total)

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