我正在向医院报告每日患者的情况。我的patient_ref_master
包含新老患者。我把2列作为新的,旧的。我想以这样的方式获取报告:当患者年老时,患者身份应该在旧栏目之下,否则患者身份应该是新的。我将存储过程的结果绑定到报表。当我将SP的结果绑定到使用C#代码中的datable进行操作的网格时,它可以正常工作。但是当我尝试使用.RDLC报告时,我也会在新旧列中获得所有患者ID。我可以在我的存储过程中使用switch case来过滤它。以下是我的存储过程。
ALTER PROCEDURE [dbo].[Daily_Report] '2013/08/02'
-- Add the parameters for the stored procedure here
-- Add the parameters for the stored procedure here
(
@date varchar(20)
)
AS
BEGIN
SET NOCOUNT ON;
SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;
SELECT
convert(varchar,Patient_Ref_master.creation_Date,105) as 'creation_Date',
Patient_Ref_master.Sr_No as 'sr_No',
old_new_patient.old_new as 'old_new',
Patient_Ref_master.Pat_ID as 'Pat_ID',
Patient_Master.Pat_FName +' '+Patient_Master.Pat_SName as 'NAME',
Dept_ID as 'Dept_ID',
Dept_Master.Dept_Name as 'Dept_Name',
Doc_Master.Doc_ID as 'Doc_Master',
Doc_Master.Doc_FName+' '+Doc_Master.Doc_SName as 'Doc_Name',
Patient_Master.Pat_Addr as 'addr',
Gender_master.Name1 as 'Pat_Sex',
Patient_Master.Age as 'age'
FROM Patient_Ref_master
left join dbo.old_new_patient on dbo.old_new_patient.code=Patient_Ref_master.old_new
left join dbo.Dept_Master on Dept_Master.Dept_code = Patient_Ref_master.Dept_ID
left join Patient_Master on Patient_Master.Pat_Code=Patient_Ref_master.Pat_ID
left join Doc_Master on Doc_Master.Doc_ID=Patient_Ref_master.Doc_ID
left join Gender_master on Gender_master.Code=Patient_Master.Pat_Sex
where
Patient_Ref_master.creation_Date=@date
--MONTH(Patient_Ref_master.creation_Date)=@month and Dept_ID=@dept
order by Patient_Ref_master.Sr_No asc
I want something like the following. where 1st row has the patient for 2nd aug under Patient_ID_New column because he is new and 2nd line because he is old. I want a blank space like 1st row in Patient_Id_Old coumn
Date No Patient_ID_New Patient ID Old
02-08-2013 11 11
02-08-2013 13 1
答案 0 :(得分:3)
是的,您可以使用case语句:
Select
(Case when "condition for oldpatient" Then PatientName Else Null End) Old_Patient,
(Case when "condition for Newpatient" Then PatientName Else Null End) New_Patient
From TableName
答案 1 :(得分:0)
SELECT
convert(varchar,Patient_Ref_master.creation_Date,105) as 'creation_Date',
Patient_Ref_master.Sr_No as 'sr_No',
Case When old_new_patient.old_new = 0x1 Then old_new_patient.old_new
Else Patient_Ref_master.Pat_ID
End as 'Pat_ID',
Patient_Master.Pat_FName +' '+Patient_Master.Pat_SName as 'NAME',