【问题标题】:SSRS display basic informationSSRS显示基本信息
【发布时间】:2017-03-09 05:43:50
【问题描述】:

如果员工请假,则显示数据

enter image description here

期望的输出

但如果其他员工没有请假,则应在给定字段中显示基本信息

enter image description here

无论他是否请假,我都希望填写基本信息字段

这是查询

  select LeaveRequest.LeaveRequestID,LeaveRequest.EmployeeID,userName,departmentName,designationName,RequestDate
  ,IsApproved,ApprovedDate,StartDate,EndDate,Name,PartOFDay 
  fromLeaveRequest
  inner join LeaveType
  on LeaveRequest.TypeID=LeaveType.TypeID

  inner join LeaveRequestDetails
  on LeaveRequest.LeaveRequestID=LeaveRequestDetails.LEaveRequestID

  inner join EmployeeInformation
  on LeaveRequest.EmployeeID=EmployeeInformation.employeeID

  inner join Departments
  on Departments.departmentID=EmployeeInformation.departmentID

  inner join Designations
  on Designations.designationID=EmployeeInformation.designationID

  where EmployeeInformation.employeeID=@empID**

【问题讨论】:

  • 作为一种好的做法,我总是从包含始终存在的数据的表开始,在本例中是您的 EmployeeInformation 表。然后对可能有也可能没有相关数据的表进行左连接。我发现它的可视化要简单得多。

标签: mysql sql sql-server join reporting-services


【解决方案1】:

问题在于 EmployeeInformation 上的 INNER JOIN,因为它过滤掉了不在 LeaveRequest 表中的任何员工 ID。 尝试将其更改为右连接:

right join EmployeeInformation
  on LeaveRequest.EmployeeID=EmployeeInformation.employeeID

【讨论】:

    【解决方案2】:

    用左外连接替换你的内连接。

    谢谢, SK

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-11-06
      • 1970-01-01
      • 1970-01-01
      • 2013-11-06
      • 2021-08-03
      相关资源
      最近更新 更多