How to get data from two rows which has same data in all columns except one in MSSQL

by Nikson   Last Updated April 20, 2018 05:06 AM

As in my title I want to get data from 2 rows which has same data in all columns except one column in any one row.you can get idea if you see the below details .

Query :

BEGIN
    SELECT 
        EPI.ITEM_CODE, LMP.PROD_DESC, LLPC.COLOC_PROD_PRICE,
        BASE_PATH + '' + EPI.IMAGE_FOLDER_NAME + '/' + EPI.IMAGE_DESCRIPTION AS POPULAR_PRODUCTS_IMAGE_PATHS
    FROM 
        ECOM_PRODUCT_IMAGES EPI
    INNER JOIN 
        ECOM_POPULAR_PRODUCTS_MAPPING EPPIM ON EPPIM.ITEM_CODE = EPI.ITEM_CODE
    INNER JOIN 
        LOM_MST_PRODUCT LMP ON LMP.PROD_CODE = EPI.ITEM_CODE 
    INNER JOIN 
        LOM_LNK_PROD_COMP LLPC ON LLPC.COLOC_PROD_CODE = LMP.PROD_CODE
    WHERE 
        EPPIM.ITEM_STATUS = 'ACTIVE'
END

Result :

enter image description here

I want to merge the result as in the below format :

enter image description here

Here for every product code I got two rows of data ,But in one row(POPULAR_PRODUCT_IMAGE_PATHS) column contains different data .I want to take that different data value as a new column value in result set .

Please help me to solve this issue. Thanks.



Related Questions



Full text catalog missing a keyword

Updated August 23, 2017 13:06 PM


MSDTC Issue SQL Server 2008 R2

Updated August 23, 2016 08:04 AM



Cache file /home/queryxchang/public_html/apps/frontend/config/../cache/-q-7-204489-how-to-get-data-from-two-rows-which-has-same-data-in-all-columns-except-one-in-mssql- could not be written