我有一个为 SSRS 报告提供信息的 SQL 查询。该报告今天停止工作,我检查了查询,它也没有工作。我看不出查询有什么问题,但它不会运行。任何帮助将不胜感激,我今天真的需要将此报告重新在线,这是产生的错误:
Msg 8180, Level 16, State 1, Line 1
Statement(s) could not be prepared.
Msg 207, Level 16, State 1, Line 1
Invalid column name 'Expr2522'.
Msg 4104, Level 16, State 1, Line 1
The multi-part identifier "Tbl1172.ShortDescription" could not be bound.
Msg 4104, Level 16, State 1, Line 1
The multi-part identifier "Tbl1170.ShortDescription" could not be bound.
Msg 4104, Level 16, State 1, Line 1
The multi-part identifier "Tbl1168.ShortDescription" could not be bound.
Msg 4104, Level 16, State 1, Line 1
The multi-part identifier "Tbl1166.Exam" could not be bound.
Msg 4104, Level 16, State 1, Line 1
The multi-part identifier "Tbl1166.PVHigh" could not be bound.
Msg 4104, Level 16, State 1, Line 1
The multi-part identifier "Tbl1166.PVAch" could not be bound.
Msg 4104, Level 16, State 1, Line 1
The multi-part identifier "Tbl1166.PVComp" could not be bound.
Msg 4104, Level 16, State 1, Line 1
The multi-part identifier "Tbl1166.PVCont" could not be bound.
Msg 4104, Level 16, State 1, Line 1
The multi-part identifier "Tbl1166.PVFund" could not be bound.
Msg 4104, Level 16, State 1, Line 1
The multi-part identifier "Tbl1166.PVXfr" could not be bound.
Msg 4104, Level 16, State 1, Line 1
The multi-part identifier "Tbl1166.PVStart" could not be bound.
Msg 4104, Level 16, State 1, Line 1
The multi-part identifier "Tbl1166.PG_DifficultyOrDisabilityID" could not be bound.
Msg 4104, Level 16, State 1, Line 1
The multi-part identifier "Tbl1166.PG_EthnicityID" could not be bound.
Msg 4104, Level 16, State 1, Line 1
The multi-part identifier "Tbl1166.PG_SexID" could not be bound.
Msg 4104, Level 16, State 1, Line 1
The multi-part identifier "Tbl1166.ExpEndYrNumber" could not be bound.
Msg 4104, Level 16, State 1, Line 1
The multi-part identifier "Tbl1166.LR_MYSID" could not be bound.
Msg 207, Level 16, State 1, Line 1
Invalid column name 'Col5840'.
Msg 207, Level 16, State 1, Line 1
Invalid column name 'Col5843'.
Msg 207, Level 16, State 1, Line 1
Invalid column name 'Col5849'.
这是我的查询:
WITH All_Genders_LLDDs_Ethns as (SELECT
Gender,
LLDD,
Ethnicity,
PG_AgeBandID,
AgeBand,
AgeGroup
FROM
(SELECT 'Male' as Gender
UNION ALL SELECT 'Female' as Gender) as Genders,
(SELECT 'LLDD' as LLDD
UNION ALL SELECT 'NO_LLDD' as LLDD) as LLDDs,
(SELECT 'WB' as Ethnicity
UNION ALL SELECT 'NWB' as Ethnicity) as Ethnicities,
(SELECT DISTINCT
PG_AgeBandID,
ab.Description as AgeBand,
ag.Description as AgeGroup
FROM
MSQL2.ProAchieve.dbo.LR_MYSHighByLevel l
LEFT JOIN MSQL2.ProGeneral.dbo.AgeBand ab on l.PG_AgeBandID = ab.AgeBandID
LEFT JOIN MSQL2.ProGeneral.dbo.AgeGroup ag on l.PG_AgeGroupID = ag.AgeGroupID
WHERE
l.PG_QType3ID not in ('30','40') and
l.LR_MYSID in (SELECT
Setting
FROM
msql2.ProAchieve.dbo.SystemSetting
WHERE
Code='DefaultLRSummary') AND
l.PG_ExpEndYrID IN ('11/12')) as AGE_Bands
),
CoreProAchData as (SELECT
al.AgeBand,
al.AgeGroup,
lml.LR_MYSID,
al.Gender,
al.LLDD,
al.Ethnicity,
lml.EthnicityDetails,
lml.LDDetails,
lml.DisabilityDetails,
'' AS Details,
al.PG_AgeBandID,
lml.PG_ExpEndYrID,
lml.ExpEndYrNumber,
sum(lml.pvstart) as pvstart,
sum(lml.PVXfr) as PVXfr,
sum(lml.PVFund) as PVFund,
sum(lml.PVCont) as PVCont,
sum(lml.PVComp) as PVComp,
sum(lml.PVAch) as PVAch,
sum(lml.PVHigh) as PVHigh,
sum(lml.exam) as exam
FROM
All_Genders_LLDDs_Ethns al
LEFT JOIN (SELECT
CASE WHEN l.PG_AgeGroupID = '1' THEN '16-18' ELSE '19+' END as AgeGroup,
CASE WHEN l.PG_SexID = 'M' THEN 'Male' ELSE 'Female' END as Gender,
CASE WHEN l.PG_EthnicityID IN ('23','31') THEN 'WB' ELSE 'NWB' END as Ethnicity,
CASE WHEN l.PG_DifficultyOrDisabilityID IN ('1') THEN 'LLDD' ELSE 'NO_LLDD' END as LLDD,
e.ShortDescription AS EthnicityDetails,
ld.ShortDescription AS LDDetails,
d.ShortDescription AS DisabilityDetails,
l.*
FROM
MSQL2.ProAchieve.dbo.LR_MYSHighByLevel l
INNER JOIN MSQL2.ProGeneral.dbo.Ethnicity e ON e.EthnicityID = l.PG_EthnicityID
INNER JOIN MSQL2.ProGeneral.dbo.LearningDifficulty ld ON ld.LearningDifficultyID = l.PG_LearningDifficultyID
INNER JOIN MSQL2.ProGeneral.dbo.Disability d ON d.DisabilityID = l.PG_DisabilityID
WHERE
l.PG_QType3ID not in ('30','40') and
l.LR_MYSID in (SELECT
Setting
FROM
msql2.ProAchieve.dbo.SystemSetting
WHERE
Code='DefaultLRSummary') AND
l.PG_ExpEndYrID IN ('11/12')
)lml on al.Gender = lml.Gender and
al.LLDD = lml.LLDD and
al.Ethnicity = lml.Ethnicity and
al.PG_AgeBandID = lml.PG_AgeBandID
GROUP BY
al.AgeBand,
al.AgeGroup,
lml.LR_MYSID,
al.Gender,
al.LLDD,
al.Ethnicity,
lml.EthnicityDetails,
lml.LDDetails,
lml.DisabilityDetails,
al.PG_AgeBandID,
lml.PG_ExpEndYrID,
lml.ExpEndYrNumber)
SELECT
*
FROM
(
SELECT
--AgeBand,
--PG_AgeBandID,
AgeGroup,
'Gender' as Stat_Type,
Gender as Grouping_Val,
'' AS Details,
sum(isnull(pvstart,0)) as starts,
sum(isnull(PVXfr,0)) as transfers,
sum(isnull(PVFund,0)) as LSC_funded,
sum(isnull(PVCont,0)) as continuing,
sum(isnull(PVComp,0)) as completed,
sum(isnull(PVAch,0)) as achieved,
sum(isnull(PVHigh,0)) as highgrades,
sum(isnull(exam,0)) as exam_taken_not_know,
ReportingFramework.dbo.fsCIS_CalculatePercentages(sum(isnull(PVAch,0)) , sum(isnull(pvstart,0))) AS 'Success Rate',
ReportingFramework.dbo.fsCIS_CalculatePercentages(sum(isnull(PVComp,0)) + sum(isnull(PVCont,0)) , sum(pvstart)) AS 'Retention Rate',
ReportingFramework.dbo.fsCIS_CalculatePercentages(sum(isnull(PVAch,0)) , sum(isnull(pvcomp,0))) AS 'Achievment Rate'
FROM
CoreProAchData
GROUP BY
--AgeBand,
--PG_AgeBandID,
AgeGroup,
Gender
UNION ALL SELECT
--AgeBand,
--PG_AgeBandID,
AgeGroup,
'LLDD Break Down' as Stat_Type,
'Learning Difficulty' as Grouping_Val,
LDDetails AS Details,
sum(isnull(pvstart,0)) as starts,
sum(isnull(PVXfr,0)) as transfers,
sum(isnull(PVFund,0)) as LSC_funded,
sum(isnull(PVCont,0)) as continuing,
sum(isnull(PVComp,0)) as completed,
sum(isnull(PVAch,0)) as achieved,
sum(isnull(PVHigh,0)) as highgrades,
sum(isnull(exam,0)) as exam_taken_not_know,
ReportingFramework.dbo.fsCIS_CalculatePercentages(sum(isnull(PVAch,0)) , sum(isnull(pvstart,0))) AS 'Success Rate',
ReportingFramework.dbo.fsCIS_CalculatePercentages(sum(isnull(PVComp,0)) + sum(isnull(PVCont,0)) , sum(pvstart)) AS 'Retention Rate',
ReportingFramework.dbo.fsCIS_CalculatePercentages(sum(isnull(PVAch,0)) , sum(isnull(pvcomp,0))) AS 'Achievment Rate'
FROM
CoreProAchData
WHERE
LDDetails != 'none' AND
LDDetails != 'not known/not provided'
GROUP BY
--AgeBand,
--PG_AgeBandID,
AgeGroup,
LDDetails
UNION ALL SELECT
--AgeBand,
--PG_AgeBandID,
AgeGroup,
'LLDD Break Down' as Stat_Type,
'No Learning Difficulty' as Grouping_Val,
LDDetails AS Details,
sum(isnull(pvstart,0)) as starts,
sum(isnull(PVXfr,0)) as transfers,
sum(isnull(PVFund,0)) as LSC_funded,
sum(isnull(PVCont,0)) as continuing,
sum(isnull(PVComp,0)) as completed,
sum(isnull(PVAch,0)) as achieved,
sum(isnull(PVHigh,0)) as highgrades,
sum(isnull(exam,0)) as exam_taken_not_know,
ReportingFramework.dbo.fsCIS_CalculatePercentages(sum(isnull(PVAch,0)) , sum(isnull(pvstart,0))) AS 'Success Rate',
ReportingFramework.dbo.fsCIS_CalculatePercentages(sum(isnull(PVComp,0)) + sum(isnull(PVCont,0)) , sum(pvstart)) AS 'Retention Rate',
ReportingFramework.dbo.fsCIS_CalculatePercentages(sum(isnull(PVAch,0)) , sum(isnull(pvcomp,0))) AS 'Achievment Rate'
FROM
CoreProAchData
WHERE
LDDetails = 'none'
GROUP BY
--AgeBand,
--PG_AgeBandID,
AgeGroup,
LDDetails
UNION ALL SELECT
--AgeBand,
--PG_AgeBandID,
AgeGroup,
'LLDD Break Down' as Stat_Type,
'Unknown' as Grouping_Val,
LDDetails AS Details,
sum(isnull(pvstart,0)) as starts,
sum(isnull(PVXfr,0)) as transfers,
sum(isnull(PVFund,0)) as LSC_funded,
sum(isnull(PVCont,0)) as continuing,
sum(isnull(PVComp,0)) as completed,
sum(isnull(PVAch,0)) as achieved,
sum(isnull(PVHigh,0)) as highgrades,
sum(isnull(exam,0)) as exam_taken_not_know,
ReportingFramework.dbo.fsCIS_CalculatePercentages(sum(isnull(PVAch,0)) , sum(isnull(pvstart,0))) AS 'Success Rate',
ReportingFramework.dbo.fsCIS_CalculatePercentages(sum(isnull(PVComp,0)) + sum(isnull(PVCont,0)) , sum(pvstart)) AS 'Retention Rate',
ReportingFramework.dbo.fsCIS_CalculatePercentages(sum(isnull(PVAch,0)) , sum(isnull(pvcomp,0))) AS 'Achievment Rate'
FROM
CoreProAchData
WHERE
LDDetails = 'not known/not provided'
GROUP BY
--AgeBand,
--PG_AgeBandID,
AgeGroup,
LDDetails
UNION ALL SELECT
--AgeBand,
--PG_AgeBandID,
AgeGroup,
'LLDD Break Down' as Stat_Type,
'Disability' as Grouping_Val,
DisabilityDetails AS Details,
sum(isnull(pvstart,0)) as starts,
sum(isnull(PVXfr,0)) as transfers,
sum(isnull(PVFund,0)) as LSC_funded,
sum(isnull(PVCont,0)) as continuing,
sum(isnull(PVComp,0)) as completed,
sum(isnull(PVAch,0)) as achieved,
sum(isnull(PVHigh,0)) as highgrades,
sum(isnull(exam,0)) as exam_taken_not_know,
ReportingFramework.dbo.fsCIS_CalculatePercentages(sum(isnull(PVAch,0)) , sum(isnull(pvstart,0))) AS 'Success Rate',
ReportingFramework.dbo.fsCIS_CalculatePercentages(sum(isnull(PVComp,0)) + sum(isnull(PVCont,0)) , sum(pvstart)) AS 'Retention Rate',
ReportingFramework.dbo.fsCIS_CalculatePercentages(sum(isnull(PVAch,0)) , sum(isnull(pvcomp,0))) AS 'Achievment Rate'
FROM
CoreProAchData
WHERE
DisabilityDetails != 'no disability' AND
DisabilityDetails != 'not known/not provided'
GROUP BY
--AgeBand,
--PG_AgeBandID,
AgeGroup,
DisabilityDetails
UNION ALL SELECT
--AgeBand,
--PG_AgeBandID,
AgeGroup,
'LLDD Break Down' as Stat_Type,
'No Disability' as Grouping_Val,
DisabilityDetails AS Details,
sum(isnull(pvstart,0)) as starts,
sum(isnull(PVXfr,0)) as transfers,
sum(isnull(PVFund,0)) as LSC_funded,
sum(isnull(PVCont,0)) as continuing,
sum(isnull(PVComp,0)) as completed,
sum(isnull(PVAch,0)) as achieved,
sum(isnull(PVHigh,0)) as highgrades,
sum(isnull(exam,0)) as exam_taken_not_know,
ReportingFramework.dbo.fsCIS_CalculatePercentages(sum(isnull(PVAch,0)) , sum(isnull(pvstart,0))) AS 'Success Rate',
ReportingFramework.dbo.fsCIS_CalculatePercentages(sum(isnull(PVComp,0)) + sum(isnull(PVCont,0)) , sum(pvstart)) AS 'Retention Rate',
ReportingFramework.dbo.fsCIS_CalculatePercentages(sum(isnull(PVAch,0)) , sum(isnull(pvcomp,0))) AS 'Achievment Rate'
FROM
CoreProAchData
WHERE
DisabilityDetails = 'no disability'
GROUP BY
--AgeBand,
--PG_AgeBandID,
AgeGroup,
DisabilityDetails
UNION ALL SELECT
--AgeBand,
--PG_AgeBandID,
AgeGroup,
'LLDD Break Down' as Stat_Type,
'Unknown' as Grouping_Val,
DisabilityDetails AS Details,
sum(isnull(pvstart,0)) as starts,
sum(isnull(PVXfr,0)) as transfers,
sum(isnull(PVFund,0)) as LSC_funded,
sum(isnull(PVCont,0)) as continuing,
sum(isnull(PVComp,0)) as completed,
sum(isnull(PVAch,0)) as achieved,
sum(isnull(PVHigh,0)) as highgrades,
sum(isnull(exam,0)) as exam_taken_not_know,
ReportingFramework.dbo.fsCIS_CalculatePercentages(sum(isnull(PVAch,0)) , sum(isnull(pvstart,0))) AS 'Success Rate',
ReportingFramework.dbo.fsCIS_CalculatePercentages(sum(isnull(PVComp,0)) + sum(isnull(PVCont,0)) , sum(pvstart)) AS 'Retention Rate',
ReportingFramework.dbo.fsCIS_CalculatePercentages(sum(isnull(PVAch,0)) , sum(isnull(pvcomp,0))) AS 'Achievment Rate'
FROM
CoreProAchData
WHERE
DisabilityDetails = 'not known/not provided'
GROUP BY
--AgeBand,
--PG_AgeBandID,
AgeGroup,
DisabilityDetails
UNION ALL SELECT
--AgeBand,
--PG_AgeBandID,
AgeGroup,
'LLDD' as Stat_Type,
CASE WHEN LLDD ='NO_LLDD' THEN 'No ' ELSE '' END + 'Learning Disability / Difficulty' as Grouping_Val,
'' AS Details,
sum(isnull(pvstart,0)) as starts,
sum(isnull(PVXfr,0)) as transfers,
sum(isnull(PVFund,0)) as LSC_funded,
sum(isnull(PVCont,0)) as continuing,
sum(isnull(PVComp,0)) as completed,
sum(isnull(PVAch,0)) as achieved,
sum(isnull(PVHigh,0)) as highgrades,
sum(isnull(exam,0)) as exam_taken_not_know,
ReportingFramework.dbo.fsCIS_CalculatePercentages(sum(isnull(PVAch,0)) , sum(isnull(pvstart,0))) AS 'Success Rate',
ReportingFramework.dbo.fsCIS_CalculatePercentages(sum(isnull(PVComp,0)) + sum(isnull(PVCont,0)) , sum(pvstart)) AS 'Retention Rate',
ReportingFramework.dbo.fsCIS_CalculatePercentages(sum(isnull(PVAch,0)) , sum(isnull(pvcomp,0))) AS 'Achievment Rate'
FROM
CoreProAchData
GROUP BY
--AgeBand,
--PG_AgeBandID,
AgeGroup,
LLDD
UNION ALL SELECT
--AgeBand,
--PG_AgeBandID,
AgeGroup,
'Ethnicity' as Stat_Type,
CASE WHEN Ethnicity ='NWB' THEN 'Non ' ELSE '' END + 'White British' as Grouping_Val,
EthnicityDetails AS Details,
sum(isnull(pvstart,0)) as starts,
sum(isnull(PVXfr,0)) as transfers,
sum(isnull(PVFund,0)) as LSC_funded,
sum(isnull(PVCont,0)) as continuing,
sum(isnull(PVComp,0)) as completed,
sum(isnull(PVAch,0)) as achieved,
sum(isnull(PVHigh,0)) as highgrades,
sum(isnull(exam,0)) as exam_taken_not_know,
ReportingFramework.dbo.fsCIS_CalculatePercentages(sum(isnull(PVAch,0)) , sum(isnull(pvstart,0))) AS 'Success Rate',
ReportingFramework.dbo.fsCIS_CalculatePercentages(sum(isnull(PVComp,0)) + sum(isnull(PVCont,0)) , sum(pvstart)) AS 'Retention Rate',
ReportingFramework.dbo.fsCIS_CalculatePercentages(sum(isnull(PVAch,0)) , sum(isnull(pvcomp,0))) AS 'Achievment Rate'
FROM
CoreProAchData
GROUP BY
--AgeBand,
--PG_AgeBandID,
AgeGroup,
Ethnicity,
EthnicityDetails) as sub
ORDER BY
--convert(int,PG_AgeBandID),
Stat_Type,
Grouping_Val