Formatting a report in 2005

  • I have 2 tables, say ,tab1 and tab2 having the same fields-id and modifier that can be related by ID.

    TAB A id modifier

    1 a

    b

    c

    d

    e

    2 a

    and

    TAB B id modifier

    1 a

    b

    2 a

    b

    c

    Now, i want to display the result as shown below:-

    id modifierA modifierB

    1 a a

    b b

    c

    d

    e

    2 a a

    b

    c

    How could i achieve this ? Plz help me out....

  • You didn't give much detail of your issue, but I guess this should do the trick.

    DECLARE @a TABLE (

    id int,

    modifier char(1)

    )

    INSERT INTO @a VALUES (1, 'a')

    INSERT INTO @a VALUES (1, 'b')

    INSERT INTO @a VALUES (1, 'c')

    INSERT INTO @a VALUES (1, 'd')

    INSERT INTO @a VALUES (1, 'e')

    INSERT INTO @a VALUES (2, 'a')

    DECLARE @b-2 TABLE (

    id int,

    modifier char(1)

    )

    INSERT INTO @b-2 VALUES (1, 'a')

    INSERT INTO @b-2 VALUES (1, 'b')

    INSERT INTO @b-2 VALUES (2, 'a')

    INSERT INTO @b-2 VALUES (2, 'b')

    INSERT INTO @b-2 VALUES (2, 'c')

    SELECT ISNULL(A.id, B.id) AS id,

    A.modifier AS modifierA,

    B.modifier AS modifierB

    FROM @a AS A

    FULL JOIN @b-2 AS B

    ON A.ID = B.ID

    AND A.modifier = B.modifier

    Hope this helps

    Gianluca

    -- Gianluca Sartori

  • select 1 as tblid,column1,column2 from table1

    union all

    select 2 as tblid,column1,column2 from table2

    order by 1,2,3

  • Thank you,Very much.....Sartori...

  • You're welcome, glad I could help.

    -- Gianluca Sartori

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

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