首页 > 代码库 > sql 根据客户需用 调价查询字段

sql 根据客户需用 调价查询字段

DECLARE @vcFieldName VARCHAR(100)= nMerchantId,nUserId,dmMoney
SELECT  nMerchantId, nUserId, dmMoney, CASE WHEN CHARINDEX(nMerchantId, @vcFieldName) > 0 THEN nMerchantId
                                            ELSE 0
                                       END + CASE WHEN CHARINDEX(nUserId, @vcFieldName) > 0 THEN nUserId
                                                  ELSE 0
                                             END + CASE WHEN CHARINDEX(dmMoney, @vcFieldName) > 0 THEN dmMoney
                                                        ELSE 0
                                                   END AS dmTotal
FROM    GM.CRM_Customer

 

sql 根据客户需用 调价查询字段