Query

  • jsshivalik

    SSC Veteran

    Points: 261

    Hi

    Table 1 
    AccountId Name
    1101 aaaa
    1701 bbbb

    Table 2
    TransId Account Debit Credit RefDate Account Id
    1 203000 0 50 08-04-2019 1101
    1 208103 0 25 08-04-2019 1210
    1 660194 75 0 08-04-2019 7101
    2 203000 100 0 03-04-2019 1701
    2 208103 25 0 03-04-2019 1210
    2 660212 0 125 03-04-2019 8710
    3 203000 0 100 10-04-2019 1101
    3 208103 0 50 10-04-2019 1210
    3 660194 150 0 10-04-2019 7101

    Result

    TransId Account Debit Credit RefDate Account Id
    1 203000 0 50 08-04-2019 1101
    1 208103 0 25 08-04-2019 1210
    3 203000 0 100 10-04-2019 1101
    3 208103 0 50 10-04-2019 1210

    2 203000 0 50 08-04-2019 1701
    2 208103 0 25 08-04-2019 1210

    Thanks

    Thanks

  • Thom A

    SSC Guru

    Points: 98453

    Not sure what the purpose of your topic is here? Could you explain? Are you simply sharing us your data and your final result and want to share how you achieved that? If so, you should include the SQL and explain it; that'll really help other.

    Thanks.

    Thom~

    Excuse my typos and sometimes awful grammar. My fingers work faster than my brain does.

  • jsshivalik

    SSC Veteran

    Points: 261

    Hi

    Actually i want if TransId of AccountId (1101) has record with AccountId 1210 with same TransId as of (1101) then that record should also be displayed.

    If we link on AccountId then only 2 rows of 1101 & 1 row of 1701 will be displayed.

    Thanks

    • This reply was modified 3 weeks, 6 days ago by  jsshivalik.
  • Phil Parkin

    SSC Guru

    Points: 243846

    As you have not provided DDL and DML to allow us to use your sample data, I will provide an outline solution only.

    SELECT ...

    FROM Table2 t2

    WHERE t2.TransId in (SELECT TransId from Table1 t1 WHERE t1.AccountId = 1101)

    If the answer to your question can be found with a brief Google search, please perform the search yourself, rather than expecting one of the SSC members to do it for you.

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

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