Comparison in 2 Tables in SQL Hellow Good Afternoon, I have created a visual representation of my 2 tables and here they are.



Before I ask my question I want to explain this both tables. The table tbl_AdMastefile is the Masterfile of my system which will be the basis of comparison from my tbl_GMFormat.

My tbl_GMFormat has 3 important columns and they are Count Date,Gondola Type and No.Of Units but all of them will be used. 

Little story about this tbl_GMFormat : Everytime I will import an Excel file in my program and I will fetch those data.

How can I achieve this ?



Let me explain the Image above, I want to compare those data that is same on the following columns Outlet Name and Gondola Type If the data has no match then leave it blank or else compare them.

I hope someone helps me.
If as You explain in parallel question - Combine two Data from 2 Tables using SQL

Your current database MS SQL Server, You can start from:

SELECT 
    tbl_ADMasterfile.QuartNo,
    tbl_ADMasterfile.SORG,
    tbl_ADMasterfile.Ace_Code,
    tbl_ADMasterfile.Outlet_Code,
    tbl_ADMasterfile.Outlet_Name,
    tbl_ADMasterfile.RSM,
    tbl_ADMasterfile.KAS,
    tbl_ADMasterfile.Gondola_Type,
    tbl_ADMasterfile.No_Of_Unit,
    tbl_ADMasterfile.Rent_Unit,
    tbl_ADMasterfile.Monthly_Rental,
    tbl_GMFormat.Count_Date,
    tbl_GMFormat.Gondola_Type
    tbl_GMFormat.no_of_units
FROM
    tbl_ADMasterfile
FULL JOIN tbl_GMFormat 
     ON tbl_ADMasterfile.Outlet_Name = tbl_GMFormat.Outlet_Name
     AND tbl_ADMasterfile.Gondola_Type = tbl_GMFormat.Gondola_Type


then You can add GROUP BY conditions (with aggregate functions) if necessary, DISTINCT You do not need (at first look)

little more information about JOINs - http://www.w3schools.com/Sql/sql_join_full.asp