-3

我得到了三个名为EasyPaisa,的表TimePay,并且Omni有字段Profitwhere EasyPasiagot (10,10), Omnigot (15,15), TimePaygot (20,20)

  1. 总利润为 20 的 EasyPaisa
  2. 总利润 30 的 Omni
  3. TimePay 总利润 40

当我用这个查询取出利润时:

SELECT 
    Sum(EasyPaisa.Profit) AS Expr1, 
    Sum(Omni.Profit) AS Expr2, 
    Sum(TimePay.Profit) AS Expr3
FROM 
    EasyPaisa, 
    Omni, 
    TimePay;

它给我的结果是实际结果的两倍

  1. EasyPaisa 利润为 40
  2. Omni 利润为 60
  3. TimePay 利润为 80
4

1 回答 1

0

你在找这个吗?

SELECT 
  (SELECT SUM(Profit) FROM EasyPaisa) Expr1,
  (SELECT SUM(Profit) FROM Omni)      Expr2, 
  (SELECT SUM(Profit) FROM TimePay)   Expr3

输出:

| EXPR1 | EXPR2 | EXPR3 |
-------------------------
|    20 |    30 |    40 |

这是SQLFiddle演示。

于 2013-06-02T06:55:31.947 回答