Need help modifying SQL query

N/a / N/A
January 21, 2009 at 08:24:29
Specs: Windows XP, 2,000 ghz

I have the following query but I get an error when I run it:

The multi-part identifier "Client.ClientUID" could not be bound.

Can anyone see why?

SELECT t1.Name, t1.PeriodName

FROM (SELECT ClientRegion.Name, ClientPeriodBrief.PeriodName, Visit.Period, Visit.VisitUID

FROM Visit
INNER JOIN BatchedVisitScores ON BatchedVisitScores.VisitUID = Visit.VisitUID AND BatchedVisitScores.BranchUID = Visit.BranchUID
INNER JOIN ClientPeriodBrief ON ClientPeriodBrief.PeriodBriefUID = Visit.Period
INNER JOIN ClientRegion ON ClientRegion.ClientUID = Client.ClientUID
INNER JOIN Branch ON Branch.BranchUID = Client.ClientUID
INNER JOIN Client ON Client.ClientUID = Branch.ClientUID
WHERE Client.ClientUID = @ClientUID
) AS t1

GROUP BY t1.PeriodName, t1.Name

See More: Need help modifying SQL query

Report •

January 26, 2009 at 13:28:40
without the schema for these tables, it's hard to give you a fixed script, but I've run a few examples here and it looks like you have one of the two possible scearions preventing you from getting this working.

1. Using a reference to an undefined table
so in your query, you are requesting SQL to join clientRegion on ClientRegion.ClientUID to Client.ClientUID but you haven't defined Client yet.

2. There is no association between the ClientRegion and previous tables.
this is a disconnect that will cause you problems.

Report •
Related Solutions

Ask Question