哎,所以我的查詢現在是結合2行同一列
ALTER PROCEDURE [SSRS].[VolumeCustomers]
@UserID int
AS
select
CaseTypeName,
COUNT(CaseNo) as CaseCount,
'Open' as indicator
FROM ORDERS.ApCase AC with (NOLOCK)
join ORDERS.CaseType CT (NOLOCK) on CT.CaseTypeID = AC.CaseTypeID
join WORKFLOW.WorkflowHistory WH (NOLOCK) on WH.EntityID = AC.CaseID and TableID = dbo.GetTableID('ApCase', 'ORDERS') and WH.Active = 1
inner join WORKFLOW.WorkflowStep WS (NOLOCK) on WS.WorkflowStepID = WH.WorkflowStepID and WS.NextStepID is null
where (AC.Active =1 and AC.CreatedDate >= DATEADD(day,-7,getdate()) and AC.CreatedDate < GETDATE())
Group By CaseTypeName
union
select
CaseTypeName,
COUNT(Caseno) as CaseCount,
'Closed' as indicator
FROM ORDERS.ApCase AC with (NOLOCK)
join ORDERS.CaseType CT (NOLOCK) on CT.CaseTypeID = AC.CaseTypeID
join WORKFLOW.WorkflowHistory WH (NOLOCK) on WH.EntityID = AC.CaseID and TableID = dbo.GetTableID('ApCase', 'ORDERS') and WH.Active = 1
join WORKFLOW.WorkflowStep WS (NOLOCK) on WS.WorkflowStepID = WH.WorkflowStepID and WS.NextStepID is not null
where (AC.Active =1 and AC.CreatedDate >= DATEADD(day,-7,getdate()) and AC.CreatedDate < GETDATE())
GROUP BY CaseTypeName
Order by CaseCount desc
和出放爲
Cytogenetics 2 All
Cytogenetics 1 Open
Flow Tech 1 All
Flow Tech 1 Open
Surgical 1 All
Surgical 1 Open
但我想的細胞遺傳學,流動技術和手術的所有出現在同一行 例如:
Cytogenetics 2 All 1 Open
Flow Tech 1 All 1 Open
Surgical 1 All 1 Open
如何編輯我的查詢,以反映這一點?
哪些值來自哪個查詢? –
查詢已關閉。你的輸出顯示它是'All'。這是一個錯字嗎? –
是它的一個錯字它應該說關閉抱歉 – MDWong