R
RayToddJr
I have a query for a report. This this query, I have a sub-query. I think I
have pinpointed my overall problem to the sub-query.
The SQL for the sub-query is listed below.
The Problem:
The purpose of the sub-query is to get the concatenated name of the property
owners and the first address. It should not contain multiple rows.
I have attempted adding the DISTINCT and the DISTINCTROW clauses to no
avail, if there is more than one owner, I still get a row for each owner with
and the associated address for that owner.
SQL for the sub-query:
SELECT taPROPERTY.PropertyID, taPROPERTY.CLT, Trim(CONCATENATE("SELECT
tadefendantnames.FirstName & ' ' & MiddleName & ' ' & LastName & ' ' &
Suffix FROM taDEFENDANTNAMES INNER JOIN taDefendants ON
taDEFENDANTNAMES.DefendantsnameID=taDEFENDANTS.DefendantsnameID WHERE
tadefendants.PropertyID=" & [taPROPERTY].[PropertyID] & " AND
tadefendants.DefendantTypeID=20")) AS Property_Owner,
taDEFENDANTNAMES.Address1 AS OwnerAddress1, taDEFENDANTNAMES.Address2 AS
OwnerAddress2, taDEFENDANTNAMES.City AS OwnerCity, taDEFENDANTNAMES.State AS
OwnerState, taDEFENDANTNAMES.Zip AS OwnerZip
FROM taPROPERTY INNER JOIN (taDEFENDANTNAMES INNER JOIN taDEFENDANTS ON
taDEFENDANTNAMES.DefendantsNameID = taDEFENDANTS.DefendantsNameID) ON
taPROPERTY.PropertyID = taDEFENDANTS.PropertyID
WHERE (((taDEFENDANTS.DefendantTypeID)=20));
In case it is needed, here is SQL for the main query:
SELECT DISTINCT taPROPERTY.PropertyID, taPROPERTY.CLT,
taTAXSALESTATUS.TaxSaleStatus, taCOURTDATA.TaxSaleNumber,
taPROPERTY.ParcelNumber, taPROPERTY.PropertyAddress,
taDEEDDESCRIPTION.DeedDescription, taCOURTDATA.CaseYear, [CaseYear]-1 AS
CaseYearOlder, [qryExhibitA4-Owner].Property_Owner,
[qryExhibitA4-Owner].OwnerAddress1, [qryExhibitA4-Owner].OwnerAddress2,
[qryExhibitA4-Owner].OwnerCity, [qryExhibitA4-Owner].OwnerState,
[qryExhibitA4-Owner].OwnerZip
FROM (taTAXSALESTATUS INNER JOIN ((taCOURTDATA INNER JOIN taPROPERTY ON
taCOURTDATA.CourtDataID = taPROPERTY.CourtDataID) LEFT JOIN taDEEDDESCRIPTION
ON taPROPERTY.PropertyID = taDEEDDESCRIPTION.PropertyID) ON
taTAXSALESTATUS.TaxSaleStatusID = taPROPERTY.TaxSaleStatusID) INNER JOIN
[qryExhibitA4-Owner] ON taPROPERTY.PropertyID =
[qryExhibitA4-Owner].PropertyID;
Thanks for any help and suggestions that can be made.
Ray.
have pinpointed my overall problem to the sub-query.
The SQL for the sub-query is listed below.
The Problem:
The purpose of the sub-query is to get the concatenated name of the property
owners and the first address. It should not contain multiple rows.
I have attempted adding the DISTINCT and the DISTINCTROW clauses to no
avail, if there is more than one owner, I still get a row for each owner with
and the associated address for that owner.
SQL for the sub-query:
SELECT taPROPERTY.PropertyID, taPROPERTY.CLT, Trim(CONCATENATE("SELECT
tadefendantnames.FirstName & ' ' & MiddleName & ' ' & LastName & ' ' &
Suffix FROM taDEFENDANTNAMES INNER JOIN taDefendants ON
taDEFENDANTNAMES.DefendantsnameID=taDEFENDANTS.DefendantsnameID WHERE
tadefendants.PropertyID=" & [taPROPERTY].[PropertyID] & " AND
tadefendants.DefendantTypeID=20")) AS Property_Owner,
taDEFENDANTNAMES.Address1 AS OwnerAddress1, taDEFENDANTNAMES.Address2 AS
OwnerAddress2, taDEFENDANTNAMES.City AS OwnerCity, taDEFENDANTNAMES.State AS
OwnerState, taDEFENDANTNAMES.Zip AS OwnerZip
FROM taPROPERTY INNER JOIN (taDEFENDANTNAMES INNER JOIN taDEFENDANTS ON
taDEFENDANTNAMES.DefendantsNameID = taDEFENDANTS.DefendantsNameID) ON
taPROPERTY.PropertyID = taDEFENDANTS.PropertyID
WHERE (((taDEFENDANTS.DefendantTypeID)=20));
In case it is needed, here is SQL for the main query:
SELECT DISTINCT taPROPERTY.PropertyID, taPROPERTY.CLT,
taTAXSALESTATUS.TaxSaleStatus, taCOURTDATA.TaxSaleNumber,
taPROPERTY.ParcelNumber, taPROPERTY.PropertyAddress,
taDEEDDESCRIPTION.DeedDescription, taCOURTDATA.CaseYear, [CaseYear]-1 AS
CaseYearOlder, [qryExhibitA4-Owner].Property_Owner,
[qryExhibitA4-Owner].OwnerAddress1, [qryExhibitA4-Owner].OwnerAddress2,
[qryExhibitA4-Owner].OwnerCity, [qryExhibitA4-Owner].OwnerState,
[qryExhibitA4-Owner].OwnerZip
FROM (taTAXSALESTATUS INNER JOIN ((taCOURTDATA INNER JOIN taPROPERTY ON
taCOURTDATA.CourtDataID = taPROPERTY.CourtDataID) LEFT JOIN taDEEDDESCRIPTION
ON taPROPERTY.PropertyID = taDEEDDESCRIPTION.PropertyID) ON
taTAXSALESTATUS.TaxSaleStatusID = taPROPERTY.TaxSaleStatusID) INNER JOIN
[qryExhibitA4-Owner] ON taPROPERTY.PropertyID =
[qryExhibitA4-Owner].PropertyID;
Thanks for any help and suggestions that can be made.
Ray.