sql server - 自己乘以值

时间:2017-01-19 10:50:58

标签: sql-server multiplication

在乘法(*)运算符而不是+运算符?中有一种聚合值的方法。对于这个例子,结果将是140(4 * 5 * 7 = 140)

SELECT  SUM(V) --*?
FROM    ( SELECT    4 V
          UNION ALL
          SELECT    5
          UNION ALL
          SELECT    7
        ) Q

1 个答案:

答案 0 :(得分:1)

       select *
    into #a --*?
    FROM    ( SELECT    4 V
              UNION ALL
              SELECT    5
              UNION ALL
              SELECT    7
            ) Q

 select EXP(SUM(LOG(v))) As value from #a

SELECT  EXP(SUM(LOG(v)))
FROM    ( SELECT    4 V
          UNION ALL
          SELECT    5
          UNION ALL
          SELECT    7
        ) Q