OUN Ash OUN Ash - 1 year ago 30
SQL Question

Oracle: two Selection in one query with multiplication and addition ,why it shows error?

I run this query given below, which shows error. I can not understand where is the problem.

SELECT T2.ENTRY_DATE , T1.OUTLET_NAME, T1.OUTLET_ADDRESS, T1.PROPRITOR_NAME, T1.MOBILE_NUMBER , T2.STATUS , T2.OUT_PRICE , ( SELECT ((T2.ITEM_CTN* T4.FACTOR)+ T2.ITEM_QTY )* T2.OUT_PRICE AS AMOUNT )
FROM T_ORDER_DETAIL T2, T_ITEM T4
WHERE T2.ITEM_ID=T4.ITEM_ID )
FROM T_OUTLET T1, T_ORDER_DETAIL T2
WHERE T2.OUTLET_ID=T1.OUTLET_ID AND T2.STATUS='Y' and T2.SR_ID=119222 and T2.ENTRY_DATE= TO_DATE('07/02/2017','dd/mm/yyyy');


The error is:


ORA-00923: FROM keyword not found where expected

Answer Source

Mam Ash, Check This.

Use JOINS.

        SELECT T2.ENTRY_DATE , T1.OUTLET_NAME, T1.OUTLET_ADDRESS, T1.PROPRITOR_NAME, T1.MOBILE_NUMBER , T2.STATUS , T2.OUT_PRICE , 
        ((T2.ITEM_CTN* T4.FACTOR)+ T2.ITEM_QTY )* T2.OUT_PRICE AS AMOUNT 
        FROM T_OUTLET T1
        inner join  T_ORDER_DETAIL T2  on 
        T2.OUTLET_ID=T1.OUTLET_ID AND T2.STATUS='Y' and T2.SR_ID=119222 and T2.ENTRY_DATE= TO_DATE('07/02/2017','dd/mm/yyyy')
        inner join T_ITEM T4 on T2.ITEM_ID=T4.ITEM_ID 
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download