Access Visual Designer 输出的原始查询:
SELECT DISTINCT
SATURN_SPRIDEN.SPRIDEN_ID,
SATURN_SPRIDEN.SPRIDEN_LAST_NAME,
SATURN_SPRIDEN.SPRIDEN_FIRST_NAME,
STUDENT_TYPE.STUDENT_TYPE_DESCRIPTION,
SATURN_SGBSTDN.SGBSTDN_TERM_CODE_EFF,
FAISMGR_RPRAWRD.RPRAWRD_OFFER_AMT AS Opportunity_Offered,
FAISMGR_RPRAWRD_1.RPRAWRD_OFFER_AMT AS Lottery_Offered,
FAISMGR_RPRAWRD_2.RPRAWRD_OFFER_AMT AS FSEOG_Offered,
FAISMGR_RPRAWRD_3.RPRAWRD_OFFER_AMT AS Pell_Offered
FROM ((((SATURN_SPRIDEN INNER JOIN (SATURN_SGBSTDN INNER JOIN STUDENT_TYPE ON SATURN_SGBSTDN.SGBSTDN_STYP_CODE = STUDENT_TYPE.STUDENT_TYPE_CODE) ON SATURN_SPRIDEN.SPRIDEN_PIDM = SATURN_SGBSTDN.SGBSTDN_PIDM)
LEFT JOIN FAISMGR_RPRAWRD ON SATURN_SPRIDEN.SPRIDEN_PIDM = FAISMGR_RPRAWRD.RPRAWRD_PIDM)
LEFT JOIN FAISMGR_RPRAWRD AS FAISMGR_RPRAWRD_1 ON SATURN_SPRIDEN.SPRIDEN_PIDM = FAISMGR_RPRAWRD_1.RPRAWRD_PIDM)
LEFT JOIN FAISMGR_RPRAWRD AS FAISMGR_RPRAWRD_2 ON SATURN_SPRIDEN.SPRIDEN_PIDM = FAISMGR_RPRAWRD_2.RPRAWRD_PIDM)
LEFT JOIN FAISMGR_RPRAWRD AS FAISMGR_RPRAWRD_3 ON SATURN_SPRIDEN.SPRIDEN_PIDM = FAISMGR_RPRAWRD_3.RPRAWRD_PIDM
WHERE (((SATURN_SGBSTDN.SGBSTDN_TERM_CODE_EFF)=[entry term]) AND ((FAISMGR_RPRAWRD.RPRAWRD_AIDY_CODE)=[aidy]) AND ((FAISMGR_RPRAWRD.RPRAWRD_FUND_CODE) In ('SNMOS','SNMOSG','SNMOSR','SNMOSF')) AND ((FAISMGR_RPRAWRD_1.RPRAWRD_AIDY_CODE)=[aidy]) AND ((FAISMGR_RPRAWRD_1.RPRAWRD_FUND_CODE)='SLOTT') AND ((FAISMGR_RPRAWRD_2.RPRAWRD_AIDY_CODE)=[aidy]) AND ((FAISMGR_RPRAWRD_2.RPRAWRD_FUND_CODE)='FSEOG') AND ((FAISMGR_RPRAWRD_3.RPRAWRD_AIDY_CODE)=[aidy]) AND ((FAISMGR_RPRAWRD_3.RPRAWRD_FUND_CODE)='FPELL'));
我如何在 Oracle SQL 中设计它以获得我想要的结果:
SELECT DISTINCT
SATURN_SPRIDEN.SPRIDEN_ID,
SATURN_SPRIDEN.SPRIDEN_LAST_NAME,
SATURN_SPRIDEN.SPRIDEN_FIRST_NAME,
STUDENT_TYPE.STUDENT_TYPE_DESCRIPTION,
SATURN_SGBSTDN.SGBSTDN_TERM_CODE_EFF,
FAISMGR_RPRAWRD.RPRAWRD_OFFER_AMT AS Opportunity_Offered,
FAISMGR_RPRAWRD_1.RPRAWRD_OFFER_AMT AS Lottery_Offered,
FAISMGR_RPRAWRD_2.RPRAWRD_OFFER_AMT AS FSEOG_Offered,
FAISMGR_RPRAWRD_3.RPRAWRD_OFFER_AMT AS Pell_Offered
FROM
SATURN_SPRIDEN
INNER JOIN SATURN_SGBSTDN
ON SATURN_SPRIDEN.SPRIDEN_PIDM = SATURN_SGBSTDN.SGBSTDN_PIDM
INNER JOIN STUDENT_TYPE
ON SATURN_SGBSTDN.SGBSTDN_STYP_CODE = STUDENT_TYPE.STUDENT_TYPE_CODE
LEFT JOIN FAISMGR_RPRAWRD
ON SATURN_SPRIDEN.SPRIDEN_PIDM = FAISMGR_RPRAWRD.RPRAWRD_PIDM
AND FAISMGR_RPRAWRD.RPRAWRD_AIDY_CODE = [aidy]
AND FAISMGR_RPRAWRD.RPRAWRD_FUND_CODE IN ('SNMOS', 'SNMOSG', 'SNMOSR', 'SNMOSF')
LEFT JOIN FAISMGR_RPRAWRD AS FAISMGR_RPRAWRD_1
ON SATURN_SPRIDEN.SPRIDEN_PIDM = FAISMGR_RPRAWRD_1.RPRAWRD_PIDM
AND FAISMGR_RPRAWRD_1.RPRAWRD_AIDY_CODE = [aidy]
AND FAISMGR_RPRAWRD_1.RPRAWRD_FUND_CODE = 'SLOTT'
LEFT JOIN FAISMGR_RPRAWRD AS FAISMGR_RPRAWRD_2
ON SATURN_SPRIDEN.SPRIDEN_PIDM = FAISMGR_RPRAWRD_2.RPRAWRD_PIDM
AND FAISMGR_RPRAWRD_2.RPRAWRD_AIDY_CODE = [aidy]
AND FAISMGR_RPRAWRD_2.RPRAWRD_FUND_CODE = 'FSEOG'
LEFT JOIN FAISMGR_RPRAWRD AS FAISMGR_RPRAWRD_3
ON SATURN_SPRIDEN.SPRIDEN_PIDM = FAISMGR_RPRAWRD_3.RPRAWRD_PIDM
AND FAISMGR_RPRAWRD_3.RPRAWRD_AIDY_CODE = [aidy]
AND FAISMGR_RPRAWRD_3.RPRAWRD_FUND_CODE = 'FPELL'
WHERE
SATURN_SGBSTDN.SGBSTDN_TERM_CODE_EFF = [entry term];
更新添加,我按照@jarlh尝试了以下建议,我的访问数据库崩溃而不是出错:
SELECT DISTINCT
SATURN_SPRIDEN.SPRIDEN_ID,
SATURN_SPRIDEN.SPRIDEN_LAST_NAME,
SATURN_SPRIDEN.SPRIDEN_FIRST_NAME,
STUDENT_TYPE.STUDENT_TYPE_DESCRIPTION,
SATURN_SGBSTDN.SGBSTDN_TERM_CODE_EFF,
FAISMGR_RPRAWRD.RPRAWRD_OFFER_AMT AS Opportunity_Offered,
FAISMGR_RPRAWRD_1.RPRAWRD_OFFER_AMT AS Lottery_Offered,
FAISMGR_RPRAWRD_2.RPRAWRD_OFFER_AMT AS FSEOG_Offered,
FAISMGR_RPRAWRD_3.RPRAWRD_OFFER_AMT AS Pell_Offered
FROM (((((( SATURN_SPRIDEN
INNER JOIN SATURN_SGBSTDN ON (SATURN_SPRIDEN.SPRIDEN_PIDM = SATURN_SGBSTDN.SGBSTDN_PIDM))
INNER JOIN STUDENT_TYPE ON (SATURN_SGBSTDN.SGBSTDN_STYP_CODE = STUDENT_TYPE.STUDENT_TYPE_CODE))
LEFT JOIN FAISMGR_RPRAWRD ON (SATURN_SPRIDEN.SPRIDEN_PIDM = FAISMGR_RPRAWRD.RPRAWRD_PIDM AND FAISMGR_RPRAWRD.RPRAWRD_AIDY_CODE=[aidy] AND FAISMGR_RPRAWRD.RPRAWRD_FUND_CODE In ('SNMOS','SNMOSG','SNMOSR','SNMOSF')))
LEFT JOIN FAISMGR_RPRAWRD AS FAISMGR_RPRAWRD_1 ON (SATURN_SPRIDEN.SPRIDEN_PIDM = FAISMGR_RPRAWRD_1.RPRAWRD_PIDM AND FAISMGR_RPRAWRD_1.RPRAWRD_AIDY_CODE=[aidy] AND FAISMGR_RPRAWRD_1.RPRAWRD_FUND_CODE='SLOTT'))
LEFT JOIN FAISMGR_RPRAWRD AS FAISMGR_RPRAWRD_2 ON (SATURN_SPRIDEN.SPRIDEN_PIDM = FAISMGR_RPRAWRD_2.RPRAWRD_PIDM AND FAISMGR_RPRAWRD_2.RPRAWRD_AIDY_CODE=[aidy] AND FAISMGR_RPRAWRD_2.RPRAWRD_FUND_CODE ='FSEOG'))
LEFT JOIN FAISMGR_RPRAWRD AS FAISMGR_RPRAWRD_3 ON (SATURN_SPRIDEN.SPRIDEN_PIDM = FAISMGR_RPRAWRD_3.RPRAWRD_PIDM AND FAISMGR_RPRAWRD_3.RPRAWRD_AIDY_CODE=[aidy] AND FAISMGR_RPRAWRD_3.RPRAWRD_FUND_CODE='FPELL'))
WHERE ((SATURN_SGBSTDN.SGBSTDN_TERM_CODE_EFF)=[entry term]) AND ((FAISMGR_RPRAWRD.RPRAWRD_AIDY_CODE)=[aidy]);
SELECT
*
FROM
(
(
(
(
(
SATURN_SPRIDEN AS SPR
INNER JOIN SATURN_SGBSTDN AS SGBS
ON SPR.SPRIDEN_PIDM = SGBS.SGBSTDN_PIDM
)
INNER JOIN STUDENT_TYPE AS STYP
ON SGBS.SGBSTDN_STYP_CODE = STYP.STUDENT_TYPE_CODE
)
LEFT JOIN FAISMGR_RPRAWRD AS FR0
ON (SPR.SPRIDEN_PIDM = FR0.RPRAWRD_PIDM
AND FR0.RPRAWRD_AIDY_CODE = [aidy]
AND FR0.RPRAWRD_FUND_CODE in ('SNMOS', 'SNMOSG','SNMOSR','SNMOSF'))
)
LEFT JOIN FAISMGR_RPRAWRD AS FR1
ON (SPR.SPRIDEN_PIDM = FR1.RPRAWRD_PIDM
AND FR1.RPRAWRD_AIDY_CODE = [aidy]
AND FR1.RPRAWRD_FUND_CODE= 'SLOTT')
)
LEFT JOIN FAISMGR_RPRAWRD AS FR2
ON (SPR.SPRIDEN_PIDM = FR2.RPRAWRD_PIDM
AND FR2.RPRAWRD_AIDY_CODE = [aidy]
AND FR2.RPRAWRD_FUND_CODE= 'FSEOG')
)
LEFT JOIN FAISMGR_RPRAWRD AS FR3
ON (SPR.SPRIDEN_PIDM = FR3.RPRAWRD_PIDM
AND FR3.RPRAWRD_AIDY_CODE = [aidy]
AND FR3.RPRAWRD_FUND_CODE= 'FPELL')
WHERE
SGBS.SGBSTDN_TERM_CODE_EFF= [entry_term];