问题描述
我需要根据使用case语句传递的参数显示结果 或者条件我该怎么办
I need to display results based on the parameter passed using case statement or if condition how can i do it
DECLARE @FullName VARCHAR(100)
DECLARE @FullName VARCHAR(100)
SET @ FullName ='Lisa S Guo' 或 SET @ FullName ='Raul'
SET @FullName='Lisa S Guo' or SET @FullName='Raul'
SELECT
Pc.ContactID,FirstName,MiddleName,LastName,
ISNULL(FirstName +''+ MiddleName +' '+ LastName,FirstName +''+ LastName) AS FullName,
TotalDue
FROM Person.Contact Pc
INNER JOIN Sales.SalesOrderHeader Ss
ON Pc.ContactID = Ss.ContactID
) AS A WHERE @ FullName = FullName
SELECT
Pc.ContactID,FirstName,MiddleName,LastName,
ISNULL(FirstName + ' ' + MiddleName + ' ' + LastName,FirstName + ' ' + LastName) AS FullName,
TotalDue
FROM Person.Contact Pc
INNER JOIN Sales.SalesOrderHeader Ss
ON Pc.ContactID=Ss.ContactID
) AS A WHERE @FullName=FullName
如果传递了其他值,它应该根据 来获取该值。案例陈述或条件
if some other value is passed it should pick up that value based on the case statement or if condition
Smash126
推荐答案
目前尚不清楚,您想申请的条件是什么?
It is not clear, what is the condition you want to apply?
这篇关于结果基于if条件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!