View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
[email protected] matt.slavicek@gmail.com is offline
external usenet poster
 
Posts: 2
Default Works in Microsoft Query, but not with QueryTables

I found out that the problem is with the CREATE OR REPLACE VIEW
statement - can you not use views with a QueryTable?

This is the query I am trying to execute - it will execute if I take
out the first 3 lines:

CREATE OR REPLACE VIEW pp_clincond
(clinical_cond, person_id, chg_allow_amt)
AS
SELECT Dx.CLINICAL_COND, Member.PERSON_ID, Sum(f.CHG_ALLOW_AMT)
FROM DRUG_CLM f,
PERIOD_PAID Per,
PERSON Member,
DX Dx WHERE f.PERIOD_PAID_KEY=Per.PERIOD_PAID_KEY
and Per.IA_LEVEL='DAY'
and f.PERSON_KEY=Member.PERSON_KEY
and f.DX_KEY=Dx.DX_KEY
and Per.ROLLING_YEAR in ('Apr 1999 - Mar 2000')
and Dx.IA_LEVEL='BASE'
and Member.PERSON_ID in ('1439608601990')
and Member.IA_LEVEL='BASE'
GROUP BY Dx.CLINICAL_COND,Dx.CLINICAL_COND,Member.PERSON_ID
UNION ALL
SELECT Dx.CLINICAL_COND, Member.PERSON_ID, Sum(f.CHG_ALLOW_AMT)
FROM PROF_CLM f,
PERIOD_PAID Per,
PERSON Member,
DX Dx
WHERE f.PERIOD_PAID_KEY=Per.PERIOD_PAID_KEY
and Per.IA_LEVEL='DAY'
and f.PERSON_KEY=Member.PERSON_KEY
and f.DX_KEY=Dx.DX_KEY
and Per.ROLLING_YEAR in ('Apr 1999 - Mar 2000')
and Dx.IA_LEVEL='BASE'
and Member.PERSON_ID in ('1439608601990')
and Member.IA_LEVEL='BASE'
GROUP BY Dx.CLINICAL_COND,Dx.CLINICAL_COND,Member.PERSON_ID
UNION ALL
SELECT Dx.CLINICAL_COND, Member.PERSON_ID, Sum(f.CHG_ALLOW_AMT)
FROM FAC_DTL f, PERIOD_PAID Per, PERSON Member, DX Dx
WHERE f.PERIOD_PAID_KEY=Per.PERIOD_PAID_KEY
and Per.IA_LEVEL='DAY'
and f.PERSON_KEY=Member.PERSON_KEY
and f.DX_KEY=Dx.DX_KEY
and Per.ROLLING_YEAR in ('Apr 1999 - Mar 2000')
and Dx.IA_LEVEL='BASE'
and Member.PERSON_ID in ('1439608601990')
and Member.IA_LEVEL='BASE'
GROUP BY Dx.CLINICAL_COND,Dx.CLINICAL_COND,Member.PERSON_ID