problem in generating the required data

  • Hi

    I'm facing a problem in generating the required data. Following are two queries with the result.

    Select

    M.MemberID,

    B.BillingId

    FROM

    dbo.Member M, dbo.Billing B

    WHERE B.MEMBERID = M.MEMBERID AND

    M.MemberId = 66835

    select MemberId, MemberEventId from MemberEvent Me where Me.MemberId = 66835

    MemberID BillingId

    ----------- -----------

    66835 268926

    66835 268927

    66835 268928

    (3 row(s) affected)

    MemberId MemberEventId

    ----------- -------------

    66835 278265

    66835 278266

    66835 278267

    66835 278272

    66835 278274

    66835 278273

    (6 row(s) affected)

    I want data form these two tables but with no repetition of MemberEventId i.e. It should return only 6 rows with three columns i.e. memberid, billingId and MemberEventId.

    Please help

  • The problem is, which BillingID do you want to use for which MemberEventID.

    I'm not sure this problem has a solution for the given data.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • I agree with Jeff.

    There doesn't appear to be a relation between memberEventID and BillingId. If you want to display the results (memberId, billingID, memberEventID), and return only 6 rows, then there would have to be a correlation between billingID and memberEventID.

    It may help if you explain what you are trying to achieve at a higher level, rather than focusing in on this query.

    Regards, Jim C

  • Thanks 4 ur comments now I’m assured that it’ll not work in this way.

    Regards Kamran :hehe:

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

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