View Single Post
  #10  
Old May 3rd, 2010, 07:41 PM posted to microsoft.public.access.reports
Marshall Barton
external usenet poster
 
Posts: 5,361
Default building a complicated (to me) string

Kathy R. wrote:
With a few changes/corrections, your SQL works quite well. Thank you
for taking so much time to work through it with me!

SELECT P.PriFirst As PriFirst, P.PriLast As PriLast, S.SecFirst As
SecFirst, S.SecLast As SecLast
FROM (SELECT X.InFamID, X.FirstName As PriFirst, X.Lastname As PriLast
FROM tblIndividual As X
WHERE X.ContactStatus = "Primary") As P
LEFT JOIN (SELECT X.InFamID, X.FirstName As SecFirst, X.Lastname As SecLast
FROM tblIndividual As X
WHERE X.ContactStatus = "Secondary") As S
ON P.InFamID = S.InFamID


On a side note, as I was searching for alternate solutions I came across
Duane Hookom's concatenation function, which also works. Both of these
solutions will go into my "keep these in mind the next time you run into
this type of problem" folder. Again, thank you for your help!


Sorry for all the typos. You did a nice job of finding and
fixing them.

We both missed one though. There is no reason to alias a
field name to itself. Here's my cleaned up version:

SELECT P.PriFirst, P.PriLast, S.SecFirst, S.SecLast
FROM (SELECT X.InFamID,
X.FirstName As PriFirst, X.Lastname As PriLast
FROM tblIndividual As X
WHERE X.ContactStatus = "Primary") As P
LEFT JOIN (SELECT X.InFamID,
X.FirstName As SecFirst, X.Lastname As SecLast
FROM tblIndividual As X
WHERE X.ContactStatus = "Secondary") As S
ON P.InFamID = S.InFamID

The Concatenate function (and many variations on that theme)
are very useful in some situations and well worth
remembering. At this point, however, it is not part of any
solution to the current question.

--
Marsh
MVP [MS Access]