我试图有一个这样的表:
Manager Expert Adminis. Staff
Dept A.P. | C.P. A.P. | C.P. A.P. | C.P.
Management 1 1 1 0 1 1
Accounting 1 1 1 1 0 0
IT 1 1 2 1 0 0
AP = 可用位置编号 CP = 当前位置编号
AP 来自名为 Positions 的表:
[Positions](
[id] [numeric](19, 0) IDENTITY(1,1) NOT NULL,
[NumOfAvailablePositions] [int] NULL,
[PositionType] [varchar](255) NULL,
[DepartmentId] [numeric](19, 0) NULL
)
CP 是 Title 表中 Title_Names 的计数:
[Title](
[id] [numeric](19, 0) IDENTITY(1,1) NOT NULL,
[Title_Name] [varchar](50) NOT NULL,
[Department_Id] [numeric](19, 0) NULL,
[Position_Type] [varchar](255) NULL,
)
总之,我试图得到这两个查询的结果:
SELECT DepartmentId, PositionType, NumOfAvailablePositions
FROM Positions
SELECT Department_Id, Position_Type, Count (Position_Type) as CurrentPositions
FROM Title group by Department_Id, Position_Type
并将结果连接到一个表中(如上所述)。
我尝试使用以下脚本加入表格:
SELECT Department_Id, PositionType, Count(Position_Type) as PositionCountTitle, Positions.DepartmentId, Positions.NumOfAvailablePositions
FROM Title, Positions
GROUP BY Position_Type, Department_Id, Positions.DepartmentId, Positions.NumOfAvailablePositions
HAVING Title.Department_Id = Positions.DepartmentId
但它产生了错误的结果。你有什么建议可以在 Jasper IReports 中解决这个问题吗?