程序有一些问题

时间:2017-07-05 06:24:23

标签: sql sql-server sql-server-2008

我有程序测试

while true
do
   echo "[CTRL+C] to stop..."
   timeout 10s ./program
done

执行测试'总部'

输出

alter Procedure [dbo].[test]
(
@Branch nvarchar(100)
)
AS
BEGIN

SELECT        res.f_Employee_Id AS Employee_Id, emp.f_Employee_Name, q.f_Question AS Question, ISNULL(ans.f_Name, res.f_Answer) AS Answer, CONVERT(nvarchar, res.f_Created_Date, 103) AS Feedback_Date, 
                     emp.f_Grade AS Grade, emp.f_Branch_DESC AS Branch
FROM            T_PAF_EmployeeResult AS res WITH (nolock) LEFT OUTER JOIN
                     t_PAF_FeedbackAns_Master AS ans WITH (nolock) ON res.f_Answer = ans.f_Code INNER JOIN
                     t_PAF_FeedbackQues_Master AS q WITH (nolock) ON res.f_Question_Id = q.f_Uid INNER JOIN
                     T_PAF_EmployeeList_2017 AS emp WITH (nolock) ON emp.f_Employee_ID = res.f_Employee_Id
WHERE        

((@Branch = emp.f_Branch_DESC) OR
                     (@Branch IS NULL)) and f_Company_Id=1031


ORDER BY Employee_Id, res.f_Question_Id
END

改变

Employee_Id f_Employee_Name     Question                                                            Answer          Feedback_Date   Grade   Branch  

1234        XYZ         My appraiser is aware of all the work i am involved in.                                     Strongly Disagree   29/06/2017  L10 C   HEAD OFFICE  

1234        XYZ         My appraiser tries to understand my point of view when he or she discusses problems or work  with me .              Disagree        29/06/2017  L10 C   HEAD OFFICE  

1234        XYZ         My appraiser has good understanding of my strengths and weaknesses.                             Neutral         29/06/2017  L10 C   HEAD OFFICE  

1234        XYZ         My appraiser gives me clear direction for the work that i am expected to do.                            Agree           29/06/2017  L10 C   HEAD OFFICE  

1234        XYZ         My appraiser provides me with necessary support to resolve issues at work (team related/client related/schedule related etc).   Strongly Agree      29/06/2017  L10 C   HEAD OFFICE 

执行测试'总部'

输出为空白

当我在我的程序中添加此代码时,它将变为空白:

alter Procedure [dbo].[test]
(
@Branch nvarchar(100)
)
AS
BEGIN

SELECT        res.f_Employee_Id AS Employee_Id, emp.f_Employee_Name, q.f_Question AS Question, ISNULL(ans.f_Name, res.f_Answer) AS Answer, CONVERT(nvarchar, res.f_Created_Date, 103) AS Feedback_Date, 
                     emp.f_Grade AS Grade, emp.f_Branch_DESC AS Branch
FROM            T_PAF_EmployeeResult AS res WITH (nolock) LEFT OUTER JOIN
                     t_PAF_FeedbackAns_Master AS ans WITH (nolock) ON   res.f_Answer = ans.f_Code INNER JOIN
                     t_PAF_FeedbackQues_Master AS q WITH (nolock) ON res.f_Question_Id = q.f_Uid INNER JOIN
                     T_PAF_EmployeeList_2017 AS emp WITH (nolock) ON emp.f_Employee_ID = res.f_Employee_Id

WHERE        

        ((@Branch = emp.f_Branch_DESC) OR
                     (@Branch IS NULL)) and f_Company_Id=1031
        and
        (
            ans.f_Name in ('Agree','Disagree') or res.f_Answer in ('Agree','Disagree')
        )


ORDER BY Employee_Id, res.f_Question_Id
END

1 个答案:

答案 0 :(得分:3)

在你的情况下试试这个

and 
( 
      ISNULL(ans.f_Name, res.f_Answer) like '%Agree%'
)
相关问题