Trying to figure out why it's erroring on pm.OrganizationName' or at least that's what it seems like is the issue?
Here's the subquery, using a derived table "pm".
When I remove it, it works but having it it errors.
Anyone know what can be fixed so that the field can remain in the formula?
SELECT DISTINCT
person.MembershipNumber, person.FirstName + ' ' + person.LastName AS NAME, person.FirstName, person.RegionId AS REGION,
addr.StreetOne, addr.StreetTwo, ISNULL(unit.Description, '') + ' ' + addr.SubUnit AS 'Unit', addr.City + ', ' + addrState.Code + ' ' + addr.PostalCode AS 'CityStateZip',
addrState.Code AS 'State', lookup.Country.Description AS 'Country', CONVERT(char(10), pm.EndDate, 101) AS EndDate, addr.PostalCode,
pm. 'OrganizationName'
FROM (SELECT attribute.PersonMembership.PersonId, ISNULL(org.OrganizationName, N'Individual') AS 'OrganizationName',
attribute.PersonMembership.MembershipTypeId, attribute.PersonMembership.InvoiceNumber, attribute.PersonMembership.EndDate
FROM attribute.PersonMembership LEFT OUTER JOIN