Print Thread
Problem with sql query
#42507 10/21/11 09:02 AM
Joined: Sep 2009
Posts: 4
G
georgie Offline OP
Member
OP Offline
Member
G
Joined: Sep 2009
Posts: 4
Hello.

Today I tried to compose a query for firm internally to be used application. The query is as:
=======================================================================================================
SELECT w.acc_date, w.deposit_base, w.cash_amount
, (w.deposit_base - (w.cash_amount / 2)) as MRR
, (w.acc_date + 3) as MRD
, w.closing_avbalance
, (s.acc_curr_bnb_select + s.acc_curr_bnb_confirm) as CURR_BNB
-- problematic part --
, (w.closing_avbalance + s.rof + (s.acc_curr_bnb_select + s.acc_curr_bnb_confirm)*1.95583)
/
(w.deposit_base - w.cash_amount/2)
-- problematic part --
, (((w.deposit_base - (w.cash_amount / 2)) / 2) - s.rof - 0 - 0) as FIFTY
, (s.acc_curr_bnb_select + s.acc_curr_bnb_confirm) / 1000000 as CURR_ORIGINAL
, s.rof
, ((w.closing_avbalance + s.rof + 0) / 1.95583) as EQUIV_EUR
FROM (
SELECT y.acc_date, y.deposit_base, y.cash_amount, b.closing_avbalance
FROM (
SELECT
DISTINCT(n.ACC_DATE) AS acc_date,
SUM(CASE WHEN n.TOTAL = 'Y' THEN n.balance_orginal END) AS deposit_base,
SUM(CASE WHEN n.BO_GROUP_NO = 1 THEN n.balance_orginal END) AS cash_amount
FROM V_N12 n
WHERE n.ACC_DATE = to_date('2010-09-30', 'rrrr-mm-dd')
GROUP BY n.ACC_DATE
) y JOIN acc.acc_balance b ON y.ACC_DATE = b.date_
WHERE b.account_id = 105
) w JOIN static_data s ON w.acc_date = s.work_date
WHERE s.work_date = to_date('2010-09-30', 'rrrr-mm-dd')
=======================================================================================================
When I try to run it I get - "ORA-936: missing expression" exception.

If I rewrite the part between the "tags", as one row: "(w.closing_avbalance + s.rof + (s.acc_curr_bnb_select + s.acc_curr_bnb_confirm)*1.95583) / (w.deposit_base - w.cash_amount/2)"
, I can run the query without any exception.

Any help as to identify the problem would be appreciated.

PL/SQL Developer: v8.0.4.1514
on Windows 7 Build 7601 (Service Pack 1)

Re: Problem with sql query
georgie #42510 10/21/11 09:20 AM
Joined: Jul 2004
Posts: 24
Germany
H
Member
Offline
Member
H
Joined: Jul 2004
Posts: 24
Germany
May be you could add additional brakets around the whole expression and add column alias.

Last edited by herzig; 10/21/11 09:20 AM.

regards

Moderated by  support 

Link Copied to Clipboard
Powered by UBB.threads™ PHP Forum Software 7.7.4
(Release build 20200307)
Responsive Width:

PHP: 7.1.33 Page Time: 0.042s Queries: 15 (0.010s) Memory: 2.4987 MB (Peak: 3.0380 MB) Data Comp: Off Server Time: 2024-05-07 21:12:26 UTC
Valid HTML 5 and Valid CSS