了解陈述

时间:2019-03-06 15:54:41

标签: sql reporting-services

我正在编写SSRS报告,并获得了一条SQL语句来检索数据。我试图理解下面的 collectionView.scrollToItem(at: IndexPath(item: 3, section: 0), at: [], animated: false) 语句SQL语句不在TSQL中,因此,我首先对其进行了转换。我不确定如何转换if条件。

if

数据集:

select s.name as FullName, s.course, s.fromdate, s.todate,dept.agency
from student as s inner join
department as dept on s.department = dept.departmentid
If lngDeptid <> 0 Then 
strReportSQL = strReportSQL & " AND department.departmentid = " & 
lngDeptid 
End If 
order by s.name

我正在尝试为select s.name as FullName, s.course, s.fromdate, s.todate,dept.agency from student as s inner join department as dept on s.department = dept.departmentid where dept.departmentid = @dept order by s.name 创建报告和下拉菜单。谁能帮助我理解dept id语句以及如何将其添加到我的数据集中?

1 个答案:

答案 0 :(得分:0)

if与SQL语句不同。您需要这样的逻辑:

select s.name as FullName, s.course, s.fromdate, s.todate, d.agency
from student  s inner join
     department d
     on s.department = d.departmentid
where @dept = 0 OR d.departmentid = @dept
order by s.name