SELECT
CASE
WHEN [AssignedUser] IS NULL
THEN 'Unassigned'
ELSE [AssignedUser]
END AS AssignedUser,
[WorkItemId], [Created] AS 'Created Date',
[AffectedUser], [TierDisplay].[DisplayString] AS 'Support Group',
[UrgencyDisplay].[DisplayString] AS 'Incident Type', [Title],
[Description]
FROM
[ServiceManagement].[dbo].[WorkItem]
JOIN
[dbo].[DisplayString] AS StatusDisplay ON StatusDisplay.ElementID = WorkItem.StatusId -- Status
JOIN
[dbo].[DisplayString] AS TierDisplay ON TierDisplay.ElementID = WorkItem.TierId -- Support Group
JOIN
[dbo].[DisplayString] AS CatagoryDisplay ON CatagoryDisplay.ElementID = WorkItem.CategoryId -- Classification
JOIN
[dbo].[DisplayString] AS UrgencyDisplay ON UrgencyDisplay.ElementID = WorkItem.Urgency -- Ugency
WHERE
WorkItemId LIKE '%IR%'
AND Created >= DATEADD(DAY, DATEDIFF(DAY, 0, GETDATE())-1, 0) --First day of previous DAY
AND Created < DATEADD(DAY, DATEDIFF(DAY,0,GETDATE()),0) --First Day of current DAY
AND [StatusDisplay].[displaystring] = 'Active' -- Only Active Status
AND [TierDisplay].[DisplayString] = 'desktop support team' -- Only Desktop support Team
ORDER BY
AssignedUser ASC
这是当前显示为
的内容
这就是我希望它显示的方式:
答案 0 :(得分:0)
您不能仅使用t-sql输出表数据。您必须获得任何报告工具(如水晶报告)的帮助,以根据您的需要组织数据。如果你真的需要它在sql server中,那么你可以使用temptable并根据你所需的结构向它添加数据。