Reputation: 31
I have a query on Oracle:
SELECT count(*),SUM(price) as total_price,
(SELECT count(*) as total_card_success FROM Card_trans WHERE status = 4)
FROM Card_trans;
When executing, it showed error:
ORA-00937: not a single-group group function
00937. 00000 - "not a single-group group function"
How to solve this prob. Thanks
Upvotes: 0
Views: 321
Reputation: 231661
If you just want to count the number of rows where status = 4
SELECT count(*),
SUM(price) as total_price,
SUM(CASE WHEN status = 4
THEN 1
ELSE 0
END) some_alias
FROM Card_trans;
Upvotes: 2