我正在尝试从Crystal Reports的用户选择中填充一条声明语句。
我是SQL和Crystal Reports的新手。不知道要尝试什么。
Declare @bldg varchar(100) = 'CTE'
Declare @Year varchar(100) = '2018-2019'
-以上几行是我试图从Crystal Report参数{?Building}和{?SchoolYear}中获取变量的内容。
select
b.text,
bsld.Address1,
bsld.City,
bsld.Zip,
bsld.Principal,
bsld.PhoneNumber,
s.Student_StudentID,
p.Person_FirstName as FirstName,
p.Person_LastName as LastName,
se.StudentEnrollment_SchoolYear,
sga.StudentGradebookAssignments_AssignmentName,
sga.StudentGradebookAssignments_StudentScore,
sga.StudentGradebookAssignments_Period,
sga.StudentGradebookAssignments_Attributes_ShortName,
sga.StudentGradebookAssignments_Attributes_Detail,
sga.StudentGradebookAssignments_Category,
sga.StudentGradebookAssignments_AssignmentDate,
se.StudentEnrollment_StartDate,
se.StudentEnrollment_EndDate,
se.StudentEnrollment_Building,
Case when sae.StudentAlternateEnrollment_StartDate is not null then 1 else 0 end as AltEnrollment
from exStudentEnrollment se
left join exStudentAlternateEnrollment sae with (nolock) on se.ForeignKey = sae.ForeignKey
join exPerson p with (nolock) on se.foreignkey = p.foreignkey
join exStudent s with (nolock) on se.foreignKey = s.foreignkey
join Building b with (nolock) on Text = StudentEnrollment_Building
join Building_SchoolLevel bsl with (nolock) on b.ID = bsl.building_Id
join BuildingSchoolLevelDetails bsld with (nolock) on bsl.ID = Building_SchoolLevel_ID
join exStudentGradebookAssignments sga with (nolock) on se.ForeignKey = sga.ForeignKey
Join StudentWorkBasedHoursLocation swbl with (nolock) on swbl.Student_ID = s.Student_StudentID
Join WorkBasedHoursLocation wbl with (nolock) on swbl.WorkBasedHoursLocation_ID= wbl.ID
join workbasedhours wbh with (nolock) on wbh.StudentWorkBasedHoursLocation_ID=swbl.ID
where ((StudentEnrollment_Building = @bldg AND StudentEnrollment_SchoolYear = @Year and StudentEnrollment_EndDate is NULL)
OR (sae.StudentAlternateEnrollment_Building = @bldg AND sae.StudentAlternateEnrollment_SchoolYear = @Year and StudentEnrollment_SchoolYear = @Year and StudentAlternateEnrollment_EndDate is NULL and StudentEnrollment_EndDate is NULL))
order by LastName,FirstName
我试图让用户选择“建筑和学年”,以将其从Crystal报表传递到SQL代码。我正在使用Crystal报表创建报表。