D
Dkline
SELECT T1.PolicyNumber, T1.[Net Investment Amount], T1.[Anticipated
Investment Fund Name], T1.[Contact Fund?], T1.[Confirm to Accounting?],
T1.[AccountID (from)], T1.[Account ID (to)], T1.[Sub Doc], T1.[Cover
Letter], T1.[Trade Date per Info Sheet (for new premium only)],
T1.[Effective Date], T1.[Wire Date], T1.[Sub Doc Date], T1.[Asset Allocation
Instructions], T1.[Client Allocation Instructions], T1.[Wire Instructions],
T1.Status, T1.Complete, T3.SiteIDNumber, T4.Custodian, T2.ID, T2.Requestor,
T2.[Request Type], T2.PolicyNumber, T2.AccountID, T2.[Date Redemption
Submitted], T2.[Requested Effective Date], T2.[Full or Partial], T2.[Partial
Amount], T2.[Date Expected], T2.[% or $ Expected], T2.[Date Residual
Expected], T2.[Residual % or $ Expected], T2.Comment
FROM ([Money Market Reserve] AS T1 INNER JOIN ([Account Inventory] AS T3
INNER JOIN [Site Inventory] AS T4 ON T3.SiteIDNumber = T4.SiteIDNumber) ON
T1.[Account ID (to)] = T3.AccountID) INNER JOIN [Pending Transactions] AS T2
ON T1.PolicyNumber = T2.PolicyNumber
UNION
SELECT T1.[PolicyNumber], T1.[Net Investment Amount], T1.[Anticipated
Investment Fund Name], T1.[Contact Fund?], T1.[Confirm to Accounting?],
T1.[AccountID (from)], T1.[Account ID (to)], T1.[Sub Doc], T1.[Cover
Letter], T1.[Trade Date per Info Sheet (for new premium only)],
T1.[Effective Date], T1.[Wire Date], T1.[Sub Doc Date], T1.[Asset Allocation
Instructions], T1.[Client Allocation Instructions], T1.[Wire Instructions],
T1.[Status], T1.[Complete], T3.[SiteIDNumber], T4.Custodian, Null, Null,
Null, Null, Null, Null, Null, Null, Null, Null, Null, Null, Null, Null
FROM ([Money Market Reserve] AS T1 INNER JOIN ([Account Inventory] AS T3
INNER JOIN [Site Inventory] AS T4 ON T3.SiteIDNumber = T4.SiteIDNumber) ON
T1.[Account ID (to)] = T3.AccountID)
WHERE [PolicyNumber] NOT IN (SELECT DISTINCT [PolicyNumber]
FROM [Pending Transactions])
UNION
SELECT T2.[PolicyNumber], Null, Null, Null, Null, Null, Null, Null, Null,
Null, Null, Null, Null, Null, Null, Null, Null, Null, Null, Null, T2.[ID],
T2.[Requestor], T2.[Request Type], T2.[PolicyNumber], T2.[AccountID],
T2.[Date Redemption Submitted], T2.[Requested Effective Date], T2.[Full or
Partial], T2.[Partial Amount], T2.[Date Expected], T2.[% or $ Expected],
T2.[Date Residual Expected], T2.[Residual % or $ Expected], T2.[Comment]
FROM [Pending Transactions] AS T2
WHERE [PolicyNumber] NOT IN (SELECT DISTINCT [PolicyNumber]
FROM [Money Market Reserve]);
I've got four tables in here.
T1 = [Money Market Reserve]
T2 = [Pending Transactions]
T3 = [Account Inventory]
T4 = [Site Inventory]
It is the "middle" one (between the two UNIONs) that is causing the
difficulty. I get an error message of "The specified filed '[PolicyNumber]'
could refer to more than one table used in the FROM clause of your SQL
statement."
If I copy just the portion above the first UNION into the SQL statement it
runs perfectly. If I copy just the bottom portion below the second UNION
into the SQL statement it runs perfectly.
I can't see straight anymore from looking at this. A second set of eyes
looking at this would be appreciated.
Investment Fund Name], T1.[Contact Fund?], T1.[Confirm to Accounting?],
T1.[AccountID (from)], T1.[Account ID (to)], T1.[Sub Doc], T1.[Cover
Letter], T1.[Trade Date per Info Sheet (for new premium only)],
T1.[Effective Date], T1.[Wire Date], T1.[Sub Doc Date], T1.[Asset Allocation
Instructions], T1.[Client Allocation Instructions], T1.[Wire Instructions],
T1.Status, T1.Complete, T3.SiteIDNumber, T4.Custodian, T2.ID, T2.Requestor,
T2.[Request Type], T2.PolicyNumber, T2.AccountID, T2.[Date Redemption
Submitted], T2.[Requested Effective Date], T2.[Full or Partial], T2.[Partial
Amount], T2.[Date Expected], T2.[% or $ Expected], T2.[Date Residual
Expected], T2.[Residual % or $ Expected], T2.Comment
FROM ([Money Market Reserve] AS T1 INNER JOIN ([Account Inventory] AS T3
INNER JOIN [Site Inventory] AS T4 ON T3.SiteIDNumber = T4.SiteIDNumber) ON
T1.[Account ID (to)] = T3.AccountID) INNER JOIN [Pending Transactions] AS T2
ON T1.PolicyNumber = T2.PolicyNumber
UNION
SELECT T1.[PolicyNumber], T1.[Net Investment Amount], T1.[Anticipated
Investment Fund Name], T1.[Contact Fund?], T1.[Confirm to Accounting?],
T1.[AccountID (from)], T1.[Account ID (to)], T1.[Sub Doc], T1.[Cover
Letter], T1.[Trade Date per Info Sheet (for new premium only)],
T1.[Effective Date], T1.[Wire Date], T1.[Sub Doc Date], T1.[Asset Allocation
Instructions], T1.[Client Allocation Instructions], T1.[Wire Instructions],
T1.[Status], T1.[Complete], T3.[SiteIDNumber], T4.Custodian, Null, Null,
Null, Null, Null, Null, Null, Null, Null, Null, Null, Null, Null, Null
FROM ([Money Market Reserve] AS T1 INNER JOIN ([Account Inventory] AS T3
INNER JOIN [Site Inventory] AS T4 ON T3.SiteIDNumber = T4.SiteIDNumber) ON
T1.[Account ID (to)] = T3.AccountID)
WHERE [PolicyNumber] NOT IN (SELECT DISTINCT [PolicyNumber]
FROM [Pending Transactions])
UNION
SELECT T2.[PolicyNumber], Null, Null, Null, Null, Null, Null, Null, Null,
Null, Null, Null, Null, Null, Null, Null, Null, Null, Null, Null, T2.[ID],
T2.[Requestor], T2.[Request Type], T2.[PolicyNumber], T2.[AccountID],
T2.[Date Redemption Submitted], T2.[Requested Effective Date], T2.[Full or
Partial], T2.[Partial Amount], T2.[Date Expected], T2.[% or $ Expected],
T2.[Date Residual Expected], T2.[Residual % or $ Expected], T2.[Comment]
FROM [Pending Transactions] AS T2
WHERE [PolicyNumber] NOT IN (SELECT DISTINCT [PolicyNumber]
FROM [Money Market Reserve]);
I've got four tables in here.
T1 = [Money Market Reserve]
T2 = [Pending Transactions]
T3 = [Account Inventory]
T4 = [Site Inventory]
It is the "middle" one (between the two UNIONs) that is causing the
difficulty. I get an error message of "The specified filed '[PolicyNumber]'
could refer to more than one table used in the FROM clause of your SQL
statement."
If I copy just the portion above the first UNION into the SQL statement it
runs perfectly. If I copy just the bottom portion below the second UNION
into the SQL statement it runs perfectly.
I can't see straight anymore from looking at this. A second set of eyes
looking at this would be appreciated.