SQL Query with Self Join

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • shahjapan
    New Member
    • Apr 2007
    • 63

    SQL Query with Self Join

    HI,
    I have a problem to make SQL query which describe below
    Problem
    Table : TbData



    AutoID | ID1 | ID2 | Status
    1 10 1 1
    2 10 2 0
    3 11 1 1
    411 2 1

    I want output like this :

    ID1 | Count(Status(1) ) | Count(Status(0) )
    10 | 1| 1
    11| 2 | 0


    How to make query for this ?

    I have to solve this problem very urgent so please if u hav any idea regarding this then guide me
    thanks in advance
    Last edited by shahjapan; Feb 18 '08, 03:52 PM. Reason: it fucks table keyword pasted from HTML
  • ck9663
    Recognized Expert Specialist
    • Jun 2007
    • 2878

    #2
    Originally posted by shahjapan
    HI,
    I have a problem to make SQL query which describe below
    Problem
    Table : TbData



    AutoID | ID1 | ID2 | Status
    1 10 1 1
    2 10 2 0
    3 11 1 1
    411 2 1

    I want output like this :

    ID1 | Count(Status(1) ) | Count(Status(0) )
    10 | 1| 1
    11| 2 | 0


    How to make query for this ?

    I have to solve this problem very urgent so please if u hav any idea regarding this then guide me
    thanks in advance

    What will happen with the second row?

    -- CK

    Comment

    Working...