SQL Select Query giving MISSING EXPRESSION - sql

I am running a query on ORACLE DB 11g and am having an issue:
select ORDER as "_id", * from orderlines;
I have this error:
ORA-00936: missing expression
00936. 00000 - "missing expression"
*Cause:
*Action:
Error at Line: 7 Column: 41
I tried it with and without the ; and still gives the error.
Thanks in advance!

As ORDER is a reserved word in many RDBMSs including Oracle, you should escape it with " :
SELECT t."ORDER" AS "_id"
, t.*
FROM "orderlines" t

Related

Oracle SQL NVL() Function

Ques : How do I will select full table with "NVL()" Oracle SQL function
Code :
SELECT NVL(ORDERNO, 'AAA') * FROM GNGRB.PRBOOK;
Error :
ORA-00936: missing expression
00936. 00000 - "missing expression"
*Cause:
*Action:
Error at Line: 11 Column: 30
Is this what you want?
SELECT NVL(ORDERNO, 'AAA') as NEWORDERNO, p.* FROM GNGRB.PRBOOK p;
This selects all rows and columns of the table, and adds another column, called ORDERNO, that replaces null values in ORDERNO with 'AAA'.
Note that this only works as long as ORDERNO is of a string-like datatype: both arguments of NVL() must have the same datatype.

SQL Error: ORA-00936: missing expression 00936. 00000 - "missing expression" *Cause: *Action:

I'm trying write an update statement that changes the passwords of customers who placed more than one
order to excellent, which contains all lowercase characters:
UPDATE customers_mgs
SET password = 'excellent'
WHERE customer_id = SELECT customer_id FROM customers_mgs WHERE count(>1 group by customer_id)
But I keep getting this error message:
Error report -
SQL Error: ORA-00936: missing expression
00936. 00000 - "missing expression"
You need parentheses around a subquery. Presumably, you also want IN rather than =:
UPDATE customers_mgs
SET password = 'excellent'
WHERE customer_id IN (SELECT customer_id
FROM customers_mgs
GROUP BY customer_id
HAVING COUNT(*) > 1
);

add const value to sql query result

I have a query:
SELECT * FROM table(i#1040_inv_adj_fn('123'))
how to add const value? This example doesn't work:
SELECT *, 'John' Name FROM table(i#1040_inv_adj_fn('123'))
error:
ORA-00923: FROM keyword not found where expected
00923. 00000 - "FROM keyword not found where expected"
*Cause:
*Action:
Error at Line: 1 Column: 9
As you did not tell us what the error is we have to guess. My guess is you need an alias for the table function, otherwise the * isn't legal:
SELECT t.*,
'Name' as John
FROM table(i#1040_inv_adj_fn('123')) t

Error executing SQL query in Oracle

I have some knowledge about SQL but a complete novice in Oracle. The following sql statement will execute properly in SQL Server. But this doesn't execute in Oracle and throws an error.
select Field1, * from Table1 where SomeField = 0
Please let know how to execute a similar statement in Oracle. The error recieved is as follows:
ORA-00936: missing expression
00936. 00000 - "missing expression"
Try,
select Field1, a.* from Table1 a where SomeField = 0;
Simply try:
select Field1, Table1.* from Table1 where SomeField = 0

Missing Expression when selecting all columns and one more

This kind of query would work perfectly in SQL Server, but it does not work in Oracle.
select issueno, * from SOMETABLE;
The error message I'm getting is:
ORA-00936: missing expression
00936. 00000 - "missing expression"
*Cause:
*Action: Error at Line: 1 Column: 16
What is wrong?
Try this, when working with oracle db you need alias when you use column name along with *
select issueno, A.* from SOMETABLE A;
On Oracle you have to include the table name or an alias to use the *. Try this:
select issueno, SOMETABLE.*
from SOMETABLE;