Ora-00936: Missing Expression Oracle

How to resolve ORA 00936 Missing Expression Error?

Remove the comma?

select /*+USE_HASH( a b ) */ to_char(date, 'MM/DD/YYYY HH24:MI:SS') as LABEL,
ltrim(rtrim(substr(oled, 9, 16))) as VALUE
from rrfh a, rrf b
where ltrim(rtrim(substr(oled, 1, 9))) = 'stata kish'
and a.xyz = b.xyz

Have a look at FROM

SELECTING from multiple tables You can include multiple tables in the
FROM clause by listing the tables with a comma in between each table
name

ORA-00936: missing expression Solution- Convert function

If this really is Oracle, then dateadd and getdate aren't Oracle functions. Look like MS SQL Server ones. Also, table is reserved word for tables, you can't name a table (or any other object) table.

Anyway: looks like this is what you might be looking for:

SELECT FECHADOC, FECHACONT, CLASEDOC, SOCIEDAD, MONEDA, 
TIPOCAMBIO, PERIODO, REFERENCIA,
TEXTOCAB, ID_REGISTRO
FROM ESQUEMA.TABLE
where to_date('20211231', 'yyyymmdd') <= trunc(sysdate) - 90;

ORA-00936: missing expression on inserting a row

As you already see, Oracle doesn't have a date or a time data type. They only have a datetime that they inappropriately call DATE.

If we want to store dates, the time part is just set to 00:00:00 (midnight). If we want to store a date with a time, we store the combination. In some rare cases do we separate date and time in two columns. This is the case when one of them can be empty (null). Thus we can distinguish midnight from "no time applies" and we can store "every day at 16:15". But, as mentioned, this is a rare case.

In your case all columns are NOT NULL columns. So, there is no reason to separate the values. The separation even makes some queries more complicated than necessary, and they become more error-prone thus.

So, change your table design:

CREATE TABLE booking
(
booking_id VARCHAR2(4) NOT NULL,
booking_time DATE NOT NULL,
checkin_time DATE NOT NULL,
checkout_time DATE NOT NULL,
number_of_adults INTEGER NOT NULL,
number_of_children INTEGER NOT NULL,
specialrequest VARCHAR2(100),
PRIMARY KEY (booking_id)
);

Then use datetime / timestamp literals to fill the table:

INSERT INTO booking
(
booking_id,
booking_time,
checkin_time,
checkout_time,
number_of_adults,
number_of_children,
specialrequest
)
VALUES
(
4011,
TIMESTAMP '2022-05-01 01:00:00',
TIMESTAMP '2022-07-01 14:00:00',
TIMESTAMP '2022-07-03 15:00:00',
2,
0,
'Birthday Cake for dinner on July 2, 2022'
);

ORA-00936: missing expression whilst executing query

The query has two issues:

  • Replace date() with trunc().
  • To use timestamp literals use to_date() (or timestamp 'literal').

For example, your query could run as:

SELECT
COUNT(*) AS count_all,
trunc(request_time) AS date_request_time,
"REQUESTS"."DEVICE_ID" AS requests_device_id
FROM
"REQUESTS"
WHERE
(
customer_id = 1
AND request_method != 'OPTIONS'
AND request_time BETWEEN to_date('2021-10-27 00:00:00', 'YYYY-MM-DD HH24:MI:SS')
AND to_date('2021-11-03 23:59:59', 'YYYY-MM-DD HH24:MI:SS')
)
AND
(
device_id IS NOT NULL
AND request_time BETWEEN to_date('2021-10-27 00:00:00', 'YYYY-MM-DD HH24:MI:SS')
AND to_date('2021-11-03 23:59:59', 'YYYY-MM-DD HH24:MI:SS')
)
GROUP BY
trunc(request_time),
"REQUESTS"."DEVICE_ID"

See running example at db<>fiddle.

Oracle CASE WHEN - ORA-00936: missing expression

The subqueries after THEN and ELSE must be enclosed inside parentheses:

SELECT * FROM TABLE1 WHERE COLUMN1 = 'YES'
AND COLUMN2 IN (
CASE
WHEN EXISTS (SELECT * FROM TABLE1 WHERE COLUMN1 = 'YES' AND COLUMN2 NOT LIKE '%NO%')
THEN (SELECT COLUMN2 FROM TABLE1 WHERE COLUMN1 = 'YES' AND COLUMN2 NOT LIKE '%YES%')
ELSE (SELECT COLUMN2 FROM TABLE1 WHERE COLUMN1 = 'YES' AND COLUMN2 NOT LIKE '%YES%')
END
)

This will work only if these subqueries don't return more than 1 row.

Also, both subqueries are the same. Is this a typo?

And IN can be changed to = since CASE returns only 1 value.

Oracle SQL - ORA-00936: missing expression

Is this what you want?

SELECT employee_id, salary FROM employees;


Related Topics



Leave a reply



Submit