ORA-00936: missing expression ORACLE please help me

Shasapo

help my final project on oracle database. i'm struggling now. anyone help me please.

this is my query

SELECT tr.id_kasir, 
       tr.tgl_transaksi, 
       sum (
            SELECT CASE tr.id_member when 'M000' 
                   then SUM ( mn.harga_menu * st.qty_menu) 
                        + SUM(mn.harga_menu*st.qty_menu) * 0.1 
                        - nvl2 ( pro.discount, 
                                       sum(mn.harga_menu * st.qty_menu) * (pro.discount/100),
                                       0) 
                   ELSE SUM(mn.harga_menu*st.qty_menu) 
                        - SUM( mn.harga_menu * st.qty_menu) * 0.05 
                        + SUM(mn.harga_menu*st.qty_menu) * 0.1
                        - nvl2 ( pro.discount, sum(mn.harga_menu * st.qty_menu) * (pro.discount/100) , 0)
                   END Setoran 
           FROM transaksi tr
          join struk st on (st.no_transaksi = tr.no_transaksi) 
          join menu mn on (st.kode_menu = mn.kode_menu )
          left outer join promo pro on (pro.kode_menu = mn.kode_menu)
          GROUP BY tr.id_kasir, tr.tgl_transaksi, tr.id_member,pro.discount 
          ORDER BY tr.tgl_transaksi, tr.id_kasir) setoran 
from transaksi tr 
group by tr.id_kasir, tr.tgl_transaksi
hashbrown

I have no idea what this query is trying but I see a few issues there. E.g. you can't use the ORDER BY inside SUM(), you can't use the SUM inside CASE this way...

Let's try fixing it by breaking the query... start with the inner part. Does the following query work?

SELECT Sum( CASE tr.id_member WHEN 'M000' 
                   then ( mn.harga_menu * st.qty_menu) 
                        +(mn.harga_menu*st.qty_menu) * 0.1 
                        - nvl2 ( pro.discount, 
                                      (mn.harga_menu * st.qty_menu) * (pro.discount/100),
                                       0) 
                   ELSE (mn.harga_menu*st.qty_menu) 
                        - ( mn.harga_menu * st.qty_menu) * 0.05 
                        + (mn.harga_menu*st.qty_menu) * 0.1
                        - nvl2 ( pro.discount, (mn.harga_menu * st.qty_menu) * (pro.discount/100) , 0)
                   ) Setoran 
           FROM transaksi tr
          join struk st on (st.no_transaksi = tr.no_transaksi) 
          join menu mn on (st.kode_menu = mn.kode_menu )
          left outer join promo pro on (pro.kode_menu = mn.kode_menu)
          GROUP BY tr.id_kasir, tr.tgl_transaksi, tr.id_member,pro.discount 

If the above query works, you can easily wrap it within the outer query.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

ORA-00936: missing expression distinct on oracle

From Dev

ORA-00936: missing expression oracle

From Dev

ORA 00936 Missing Expression

From Dev

Oracle data access error: ORA-00936: missing expression

From Dev

ora:00936 Missing Expression error

From Dev

ORA-00936: missing expression - what is the cause?

From Dev

ORA-00936: missing expression in order by case

From Dev

SQL Error -- ORA-00936: missing expression

From Dev

ORA-00936: Missing Expression Teradata

From Dev

ORA-00936: missing expression, although there seems to be no missing expression (SQL)

From Dev

ORA-00936: missing expression, although there seems to be no missing expression (SQL)

From Dev

ORA-00936: missing expression error when inserting values

From Dev

Entity Framework ExecuteStoreCommand gives {"ORA-00936: missing expression"}

From Dev

ORA-00936: missing expression bad SQL grammar

From Dev

ORA-00936: missing expression while executing in C#.

From Dev

ORA-00936: missing expression while using stringbuilder

From Dev

Sql throws 'DBError: ORA-00936: missing expression' when empty expression_list is passed

From Dev

Please help - ORA-00917: missing comma insert error

From Dev

HQL with one-to-many relationship is giving "ORA-00936: missing expression" exception

From Dev

getting java.sql.SQLSyntaxErrorException: ORA-00936: missing expression error

From Dev

HQL with one-to-many relationship is giving "ORA-00936: missing expression" exception

From Dev

Oracle SQL - ORA-00936 on DATE()

From Dev

ORA-06550: line 12, column 9: PL/SQL: ORA-00936: missing expression ORA-06550: line 9, column 5: PL/SQL: SQL Statement ignored

From Dev

Please help me with a recursive function

From Dev

Please help me understand Arrays

From Dev

Please help me delete a file?

From Dev

Please help me with this collision detection

From Dev

Please help me open it "xampp"

From Dev

Help me with broken packages please

Related Related

  1. 1

    ORA-00936: missing expression distinct on oracle

  2. 2

    ORA-00936: missing expression oracle

  3. 3

    ORA 00936 Missing Expression

  4. 4

    Oracle data access error: ORA-00936: missing expression

  5. 5

    ora:00936 Missing Expression error

  6. 6

    ORA-00936: missing expression - what is the cause?

  7. 7

    ORA-00936: missing expression in order by case

  8. 8

    SQL Error -- ORA-00936: missing expression

  9. 9

    ORA-00936: Missing Expression Teradata

  10. 10

    ORA-00936: missing expression, although there seems to be no missing expression (SQL)

  11. 11

    ORA-00936: missing expression, although there seems to be no missing expression (SQL)

  12. 12

    ORA-00936: missing expression error when inserting values

  13. 13

    Entity Framework ExecuteStoreCommand gives {"ORA-00936: missing expression"}

  14. 14

    ORA-00936: missing expression bad SQL grammar

  15. 15

    ORA-00936: missing expression while executing in C#.

  16. 16

    ORA-00936: missing expression while using stringbuilder

  17. 17

    Sql throws 'DBError: ORA-00936: missing expression' when empty expression_list is passed

  18. 18

    Please help - ORA-00917: missing comma insert error

  19. 19

    HQL with one-to-many relationship is giving "ORA-00936: missing expression" exception

  20. 20

    getting java.sql.SQLSyntaxErrorException: ORA-00936: missing expression error

  21. 21

    HQL with one-to-many relationship is giving "ORA-00936: missing expression" exception

  22. 22

    Oracle SQL - ORA-00936 on DATE()

  23. 23

    ORA-06550: line 12, column 9: PL/SQL: ORA-00936: missing expression ORA-06550: line 9, column 5: PL/SQL: SQL Statement ignored

  24. 24

    Please help me with a recursive function

  25. 25

    Please help me understand Arrays

  26. 26

    Please help me delete a file?

  27. 27

    Please help me with this collision detection

  28. 28

    Please help me open it "xampp"

  29. 29

    Help me with broken packages please

HotTag

Archive