Quantcast
Channel: Forum Getting started with SQL Server
Viewing all articles
Browse latest Browse all 4729

Compare two table columns and count ..

$
0
0

Hi friends..

I need help.. I used CTE to retrieve 40 records. i have another table "Fam" it have 1000 records.. i need to search that 40 records in that 1000 records if there is any matches then i need to show how many columns matching in each row... please help me how to achieve this..

Table1.

Col1 Col2 Col3 Col4 Col5 Col6 Col7 

Aa     Bb    Cc    Dd    Ee    Ff     Gg

AA     BB    CC   DD    EE    FF     GG

Ww   Ww  Ww  W     W    W       Ww

 

Table2.

Col1 Col2 Col3 Col4 Col5 Col6 Col7 

Aa     bc    dc     ed      fe    gf    hg

AA     BB    CC    De     Ef    Fg     Gh

Xx      X      X      xx      X      x        x

Expexting Result:

Col1 Col2 Col3 Col4 Col5 Col6 Col7  MatchingColCount 

Aa     bc    dc     ed      fe    gf    hg          1

AA     BB    CC    De     Ef    Fg     Gh         2

Like this i need to do..

Have to retrive matching rows with how many columns mathcing..Please help


Viewing all articles
Browse latest Browse all 4729

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>