Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago
Solved

Count Increased after Left join

Hello all,
I have two tables

Cntry, parts
In parts there are 30 columns and in cntry only 2 columns. I am doing Left join based on cntry_abb matching column in both tables Left tables is Parts and expaned the column Cntry_desc into parts table after join
I have 3.78M records in left table but after join it became 3.84, 8K difference  I am getting. 

How to get rid of this count increase issue?

Please Help

Thanks!!

  • Anonymous if you are linking from cntry table to part tables it will increase the count since there are duplicate in part table,

     

    but if you are doing from part table to cntry table then the count of parts table will remain the same. It is very basic thing, not sure what is the confusion here.

5 Replies

  • Anonymous if you are linking from cntry table to part tables it will increase the count since there are duplicate in part table,

     

    but if you are doing from part table to cntry table then the count of parts table will remain the same. It is very basic thing, not sure what is the confusion here.

  • Anonymous you have probably duplicate cntry_abb in parts tables.

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi parry2k , I will be having duplicates too, but I don't know how count increased and why...

  • Anonymous it will increase the count:

     

    assuming this

     

    cntry table has following records:

     

    USA 

    Canada

     

    Product table has following records

     

    USA

    USA

    Canada

    Canada

     

    and based on the above if you do a left join you will get 4 records because of duplicate in the Product table. 

    • Anonymous's avatar
      Anonymous
      Not applicable

      For example

      CNTRY TABLE:

      CNTRY_ABBCNTRY_NAME
      AUAUSTRALIA
      SPSPAIN
      EGEGYPT
      CACANADA


      PARTS TABLE:

      CNTRT_ABBPART NUMID
      AU10541
      AU10562
      SP10573
      EG10573
      CA10534
      CA10524


      If I am expanding only CNTRY_NAME Column into Parts table for CNTRY_ABB

      How the values counts are increasing then...