Problem with joining two select query statements.

  • Hi All,

    I Have Two Select Query Statement Result sets I want to combine those two sets.

    The Below One Is my first query resultant set,

    IDNAMEHOURS

    1AAA0

    2BBB10

    3CCC0

    4DDD0

    The Below One Is my Second query resultant set,

    IDNAMEHOURS

    1AAA20

    2BBB0

    3CCC0

    4DDD0

    After Joining two results i.e., My First Query & Second Query i want to get like below one,

    IDNAMEHOURS

    1AAA20

    2BBB10

    3CCC0

    4DDD0

    But i am not getting the result.

    After Joining two results i am getting the final one like below but it was wrong

    IDNAMEHOURS

    1AAA0

    1AAA20

    2BBB0

    2BBB10

    3CCC0

    4DDD0

    For the Joining two select queries am using Below Query

    Select TT.ID,TT.NAME,ROUND((CAST((Sum(TJA.MINS)) as FLOAT)/60),0) AS HOURS

    From MYTABLE1 as TT INNER JOIN MYTABLE2 as TB

    On TT.ID=TB.ID INNER JOIN MYTABLE3 as TH

    On TB.BID=TH.BID INNER JOIN MYTABLE4 as TJA

    On TJA.HID=TH.HID

    Where TJA.JID=41

    group by TT.ID,TT.NAME

    UNION

    Select TJA.ID,TT.NAME,ROUND((CAST((Sum(TJA.MINS)) as FLOAT)/60),0) AS HOURS

    From MYTABLE1 as TT INNER JOIN MYTABLE2 as TJA

    On TT.ID=TJA.ID

    wHERE TJA.JID=41

    group by TJA.ID,TT.NAME

    Please give the solution for me.

    Thanks In Advance,

    Venki Desai.

  • Duplicate post. Please post your replies here.

    http://www.sqlservercentral.com/Forums/Topic1446842-1292-1.aspx


    Kingston Dhasian

    How to post data/code on a forum to get the best help - Jeff Moden
    http://www.sqlservercentral.com/articles/Best+Practices/61537/

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

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