0
votes

I'm attempting to write a WHERE clause into a SQL statement. I want to output a date range for my data b/c Excel is trying to output more data into a worksheet than it can handle. So, this is the SQL statement. I just want o display the data >01/01/2018 and I'm not successful in getting the statement to generate.

I'm getting an error: ORA-00933: SQL Command not properly ended.

SELECT "V_RELEASES_COMB"."ITEMNO",
       "V_RELEASES_COMB"."REV",
       "V_RELEASES_COMB"."DESCRIP",
       "V_RELEASES_COMB"."ORDERNO",
       "V_RELEASES_COMB"."PONO",
       "V_RELEASES_COMB"."RELEASE_QUAN",
       "V_RELEASES_COMB"."REQUEST_DATE",
       "V_RELEASES_COMB"."PROMISE_DATE",
       "V_RELEASES_COMB"."SHIP_DATE",
       "V_RELEASES_COMB"."CUSTNO",
       "V_RELEASES_COMB"."COMPANY",
       "V_RELEASES_COMB"."DAYS_DIFF",
       "V_RELEASES_COMB"."CUMM_SHIPPED",
       "V_RELEASES_COMB"."EPLANT_ID",
       "EPLANT"."COMPANY",
       "V_RELEASES_COMB"."ACTUAL_SHIPDATE"
FROM "IQMS"."V_RELEASES_COMB" "V_RELEASES_COMB"
     LEFT OUTER JOIN "IQMS"."EPLANT" "EPLANT" ON "V_RELEASES_COMB"."EPLANT_ID" = "EPLANT"."ID"
WHERE "V_RELEASES_COMB"."SHIP_DATE" > 01 / 01 / 2018
  "V_RELEASES_COMB"."CUMM_SHIPPED" > 0
  AND "V_RELEASES_COMB"."EPLANT_ID" > 79
ORDER BY "V_RELEASES_COMB"."CUSTNO";
3
Please consider the readability of code when writing SQL; whitespace and line breaks are important parts of writing code (I've formatted it for you). On the note of your error, that isn't a SQL Server error. I suspect something is using Oracle. Now that I've formatted your code for you though, notice there's something missing before "V_RELEASES_COMB"."CUMM_SHIPPED" > 0"Larnu

3 Answers

2
votes

I cannot explain the problem you are getting. However, you should write the WHERE clause as:

WHERE "V_RELEASES_COMB"."SHIP_DATE" > DATE '2018-01-01' AND
      "V_RELEASES_COMB"."CUMM_SHIPPED" > 0 AND
      "V_RELEASES_COMB"."EPLANT_ID" > 79

You are comparing a date to a calculation -- 1 / 1 / 2018, instead of to a date.

0
votes

If "SHIP_DATE" is a date type column, you should be able to use the SQL format in the WHERE clause.

WHERE "V_RELEASES_COMB"."SHIP_DATE" > '2018-11-01'

If this does not help, can you post an example of the stored data?

0
votes

As has been said, I think instead of writing the date like this:

01 / 01 / 2018

you should write it like this:

'01/01/2018'