How to find unique values in a table

  • Mond wrote:

    Hello trying to find unique values on the following table

    First temporary table  query (Master Data)

    insert into #tempCOO select sk.CountryOfOrigin,im.partnumber,sk.Quantity,sol.id,lp.id,lpl.id,so.id,p.SerialNumber FROM  sk join  lpl on sk.LoadPlanLineId = lpl.id join  lp on lp.id = lpl.LoadPlanId join  sol(nolock) on sol.id=lpl.SalesOrderLineId join so on so.id=sol.SalesOrderId join im on im.id = sol.itemmasterid join pd on pd.content = sk.batchnumber and Pd.PackageAttributeId=37 join p on p.id=pd.PackageId where lp.Loadnumber= 'L001' order by p.SerialNumber desc

    The result is the following:

    I need to find unique values for a combination of country of Origin and Part Number

    These are the values I expect

    Could you help me to  write the querys I need?

    Thanks so much

    SELECT CountryOfOrigin, 
    PartNumber,
    SUM(Quantity) Qty,
    'x' Sol,
    'x' LoadPlanId,
    'x' SalesOrder,
    'x' PalletNumber
    FROM #tempCOO
    GROUP BY CountryOfOrigin, PartNumber
    ORDER BY CountryOfOrigin, PartNumber

     

  • This works super good:

     

    SELECT CountryOfOrigin,

    PartNumber,

    SUM(Quantity) Qty,

    'x' Sol,

    'x' LoadPlanId,

    'x' SalesOrder,

    'x' PalletNumber

    FROM #tempCOO

    GROUP BY CountryOfOrigin, PartNumber

    ORDER BY CountryOfOrigin, PartNumber

     

    thanks a lot!!!!

  • thank you so much!!

Viewing 3 posts - 16 through 18 (of 18 total)

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