oracle - ORA-00936: missing expression, although there seems to be no missing expression (SQL) -
i'm attempting calculate ratio of 2 sums, 1 of has where
clause, decided utilize subqueries:
select round(100.0*credit.luotot/all.kaikki) cpros (select sum(ordered.totalprice) kaikki ordered) all, (select sum(ordered.totalprice) luotot ordered ordered.paymentby = 'credit') credit
however, running query throws
ora-00936: missing look
and don't understand why.
all
reserved word in oracle. should utilize name isn't, such all_ordered
:
select round(100.0*credit.luotot/all_ordered.kaikki) cpros (select sum(ordered.totalprice) kaikki ordered) all_ordered, (select sum(ordered.totalprice) luotot ordered ordered.paymentby = 'credit') credit
edit: btw, can accomplish desired result case
look won't need utilize subqueries:
select round(100.0 * sum(totalprice) / sum(case paymentby when 'credit' totalprice else 0 end) cpros ordered
sql oracle
No comments:
Post a Comment