I need to combine two unrelated queries to produce needed results

  • I have two queries that I need to combine to get results together
    The first query returns 3000 customer ID's
    The second query returns 12 part  ID's and a percentage field.
    I would like my results to be 
    CustomerID PartID Percentage
    so I would end up with each customer id being listed 12 times with the 12 different partID's and the percentage field

    query 1
    select cmlOrganizationID from OrganizationLocations where cmlCustomerPaymentTermID !=''

    query 2
    select impPartID,tariff = .05,  from parts where partgroup='import'

  • kat35601 - Tuesday, October 23, 2018 1:10 PM

    I have two queries that I need to combine to get results together
    The first query returns 3000 customer ID's
    The second query returns 12 part  ID's and a percentage field.
    I would like my results to be 
    CustomerID PartID Percentage
    so I would end up with each customer id being listed 12 times with the 12 different partID's and the percentage field

    query 1
    select cmlOrganizationID from OrganizationLocations where cmlCustomerPaymentTermID !=''

    query 2
    select impPartID,tariff = .05,  from parts where partgroup='import'

    This?

    select
    orgloc.cmlOrganizationID
    , prt.impPartID
    , prt.tariff -- or is it tariff = .05
    from
    dbo.OrganizationLocations orgloc
    cross join dbo.parts prt
    where
    orgloc.cmlCustomerPaymentTermID !=''
    and prt.partgroup='import';

Viewing 2 posts - 1 through 1 (of 1 total)

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