0

我有一个关于Oracle的查询:

SELECT count(*),SUM(price) as total_price,
  (SELECT count(*) as total_card_success FROM Card_trans WHERE status = 4)
FROM Card_trans;

执行时显示错误:

ORA-00937: not a single-group group function
00937. 00000 -  "not a single-group group function"

如何解决这个问题。谢谢

4

1 回答 1

2

如果您只想计算行数status = 4

SELECT count(*),
       SUM(price) as total_price,
       SUM(CASE WHEN status = 4 
                THEN 1
                ELSE 0
            END) some_alias
  FROM Card_trans;
于 2015-09-04T02:49:50.933 回答