This is my SQL Statement thus far
INSERT INTO RegisteredDonors (firstname,
lastname,
organization,
OrganizationType,
OrganizationGroup,
OrganizationField1,
OrganizationField2,
OrganizationOther,
Website,
PrimaryEmail,
AltEmail,
PrimaryPhone,
PrimaryPhoneName,
AltPhone,
AltPhoneName,
FaxNumber,
BillingFirstName,
BillingLastName,
BillingCompany,
BillingAddressLine1,
BillingAddressLine2,
BillingCity,
BillingPostalCode,
BillingState,
BillingCountry,
ShippingFirstName,
ShippingLastName,
ShippingCompany,
ShippingAddressLine1,
ShippingAddressLine2,
ShippingCity,
ShippingPostalCode,
ShippingState,
ShippingCountry,
DateAdded,
DonorStatusCode,
qbId,
CreatedBy)
SELECT firstname,
lastname,
organization,
organization_type,
organization_group,
organization_field_1,
organization_field_2,
organization_other,
organization_website,
email,
email_alt,
telephone,
telephone_name,
telephone_alt,
telephone_alt_name,
fax,
payment_firstname,
payment_lastname,
payment_company,
payment_address_1,
payment_address_2,
payment_city,
payment_postcode,
payment_zone,
payment_country,
shipping_firstname,
shipping_lastname,
shipping_company,
shipping_address_1,
shipping_address_2,
shipping_city,
shipping_postcode,
shipping_zone,
shipping_country,
GETDATE() as CreateDate,
1 as DonorStatusCode,
qb.Id,
'Me' as CreatedBy
FROM
cart_order co
INNER JOIN
qb_customers qb ON (co.organization + ' (' + co.payment_zone + ')') = qb.FullyQualifiedName
ORDER BY
co.order_id DESC
How do I get the inner join to return the first row of results from cart_order? I am using SQL Server (Azure) and I can't figure this out. I looked at this StackOverflow answer and I am not sure if it applies correctly here.
SQL Left Join first match only
Thanks!