SQL中'%'的含义是什么?

时间:2015-03-02 15:44:45

标签: sql sql-server

我继承了一些SQL代码,其中一部分代码如下:

    CASE WHEN 
    (CAST(CAST(b.xx AS numeric(11, 6)) 
            * CAST(a.ratio AS numeric(11, 6)) AS decimal(10, 0)) % a.mktcoupons =0) 
       THEN CAST((CAST(b.xx AS numeric(11, 6)) * 
            CAST(a.ratio AS numeric(11, 6))) / a.mktcoupons AS decimal(10, 0)) 
    ELSE 
    CAST(( CAST(b.xx AS numeric(11, 6)) 
            * CAST(a.ratio AS numeric(11, 6))) / a.mktcoupons AS decimal(10, 0)) 
    + (CAST(CAST(b.xx AS numeric(11, 6)) 
        * CAST(a.ratio AS numeric(11, 6)) AS decimal(10, 0)) % a.mktcoupons) 
    END AS yy

我理解'案例的一般表达,当A然后B其他C结束' 。但是,我很难搞清楚'%'意思?我查了一下'mktcoupons'并且在“mktcoupon”中没有零价值。任何的想法?谢谢!

2 个答案:

答案 0 :(得分:4)

它是模数除法。 见这里:https://msdn.microsoft.com/de-de/library/ms190279.aspx

答案 1 :(得分:0)

如果它在数学运算中最有可能modulo

如果它在字符串中使用它基本上意味着“任意数量的任何字符”。