I am trying to run a query but for reason its keep giving me below error
ORA-00904: "DISTANCE_IN_METRES": invalid identifier
can someone please help to sort the issue, much appreciated for any help or guidance on this.
You can not use a column defined in a select clause in that same select clause. Logically a select clause is evaluated all at once. A simplified example:
select 1 as test, 2 * test from dual
ORA-00904: "TEST": invalid identifier
As kashi points out in a comment, DISTANCE_IN_METRES is referenced in the case expression following the definition of DISTANCE_IN_METRES in the same select clause, and this is where the error is coming from.
Related
Trying to insert this activity into my table but getting the error seen below. Any thoughts? SQL query checkers keep telling me its in my insert statement but I'm not seeing any outlier on my end. Thanks!
INSERT INTO
"_CEL_MD_ACTIVITIES" ("_CEL_MD_ACTIVITIES"."CASE_KEY", "_CEL_MD_ACTIVITIES"."ACTIVITY_EN", "_CEL_MD_ACTIVITIES"."EVENTTIME")
SELECT
"_CEL_MD_CASE_TABLE"."CASE_ID" AS "_CEL_MD_ACTIVITIES"."CASE_KEY",
'Case Reopened' AS "_CEL_MD_ACTIVITIES"."ACTIVITY_EN",
"_CEL_MD_CASE_TABLE"."CASE_REOPEN_DATE" AS "_CEL_MD_ACTIVITIES"."EVENTTIME"
FROM
"_CEL_MD_CASE_TABLE"
JOIN
"_CEL_MD_ACTIVITIES"
ON "_CEL_MD_CASE_TABLE"."CASE_ID" = "_CEL_MD_ACTIVITIES"."CASE_KEY"
WHERE
"_CEL_MD_CASE_TABLE"."CASE_REOPEN_DATE" IS NOT NULL;
Execution error: [Vertica]VJDBC ERROR: Syntax error at or near
"."
You use as aliases the name and fields of a table involved in the join.
For example
AS "_CEL_MD_ACTIVITIES"."ACTIVITY_EN",
This is not correct. You should change your alias names and not use dots (.) in them or remove the usage of aliases
Below is the query I tried to execute in SQL Server:
CREATE TABLE List
AS
(SELECT * FROM counts)
I get this error:
Msg 102, Level 15, State 1, Line 1
Incorrect syntax near '('
I did some research on google to understand and isolate the error, but, failed to do so. Could anyone please help me understand the error. Thank you
SQL-Server's syntax to create a table from a query is by adding an into clause:
SELECT *
INTO list
FROM counts
The query for selecting multiple values and assigning to multiple variables in a single SELECT query leads to an error. My Postgres version is 9.5.
The query is:
SELECT INTO region_id ,doc_type,tax_amt fk_bint_supplier_tax_region_id,chr_supporting_document_type,
dbl_base_currency_client_net-dbl_base_currency_market_fare-dbl_base_currency_cc_charge_collected+
dbl_base_currency_vat_in+dbl_base_currency_cc_charge_collected+(19*(dbl_base_currency_tax))*5/10
FROM tbl_sales_details WHERE chr_document_status='N' AND vchr_document_no='INV/47922/01/18'
AND vchr_supporting_document_no='5111143004'
The error is:
ERROR: syntax error at or near ","
LINE 1: SELECT INTO region_id ,doc_type,tax_amt fk_bint_supplier_ta...
^
********** Error **********
ERROR: syntax error at or near ","
SQL state: 42601
SELECT INTO in PL/pgSQL has a different meaning from
SELECT INTO in SQL. The latter is generally discouraged. The manual:
CREATE TABLE AS is functionally similar to SELECT INTO. CREATE TABLE AS
is the recommended syntax, since this form of SELECT INTO is not
available in ECPG or PL/pgSQL, because they interpret the INTO clause
differently. Furthermore, CREATE TABLE AS offers a superset of the
functionality provided by SELECT INTO.
The error message indicates you tried to run the statement as plain SQL.
There's nothing wrong with your placement of the INTO clause when used in PL/pgSQL like you tagged. You also stated that it's for:
assigning to multiple variables
That, too, only makes sense inside procedural language code as there are no variable assignments in plain SQL.
Related:
SELECT INTO with more than one attribution
You put the into after the column list:
SELECT region_id, doc_type,tax_amt fk_bint_supplier_tax_region_id, chr_supporting_document_type,
(dbl_base_currency_client_net - dbl_base_currency_market_fare -
dbl_base_currency_cc_charge_collected +
dbl_base_currency_vat_in + dbl_base_currency_cc_charge_collected + 19 * dbl_base_currency_tax
) * 5/10
INTO . . .
FROM tbl_sales_details
WHERE chr_document_status = 'N' AND
vchr_document_no = 'INV/47922/01/18' AND
vchr_supporting_document_no = '5111143004';
I don't know what the variable names are, but the go after the INTO and there must be one for each expression in the SELECT.
Hi I have the following code
SELECT entertainer_id,
entertainer_groupname
FROM casestudy_entertainer
INNER JOIN casestudy_availability ON
casestudy_entertainer.entertainer_id
= CASESTUDY_AVAILABILITY.AVAILABILITY_ENTERTAINERID
INNER JOIN casestudy_calendardates ON
CASESTUDY_AVAILABILITY.AVAILIBILITY_CALENDARDATEID
= casestudy_calendardates.calendar_Id
WHERE entertainer_type = '&Entertainer_TYPE'
AND casestudy_calendardates.calendar_date = '&Event_date'
And I don't seem to be able to figure out what its not liking when I run this.
It gives me the following error
ORA-00904: "CASESTUDY_AVAILIBILITY"."AVAILIBILITY_CALENDARDATEID": invalid identifier
00904. 00000 - "%s: invalid identifier"
*Cause:
*Action:
Error at Line: 7 Column: 4
I do have all the tables in place with all the correct rows.
The only thing is I have no data as of yet, Could this possibly be the issue?
You should try the lower case for the table/column identifiers(like in from/inner join clauses):
SELECT entertainer_id,
entertainer_groupname
FROM casestudy_entertainer
INNER JOIN casestudy_availability ON casestudy_entertainer.entertainer_id = casestudy_availability.availability_entertainerid
INNER JOIN casestudy_calendardates ON casestudy_availability.availibility_calendardateid = casestudy_calendardates.calendar_id
WHERE entertainer_type = '&Entertainer_TYPE'
AND casestudy_calendardates.calendar_date = '&Event_date'
This Error is caused by a special character in one of the columns of the database table. DBA will be able to help you.
You have same tablenames in your tables while left joining.
Change tablename of one , it will work.
no data is not the issue, you won't simply get a null result. ORA-00904 indicates, that you used a column that does not exist or does not comply to the Oracle specification.
Please check for correct naming. You might be better of with shorter names or at least table aliasses to get to code more readable.
Without knowing your table structure I cannot tell you where the error is. do a describe table_name;
It would also help to have the oracle version number SELECT * FROM V$VERSION or SELECT version FROM V$INSTANCE
and your client software you are using
What is interesting, Oracle gives that message not only if the name of the column is bad, but also if the name of the table/alias is bad - not defined alias, twice defined (as mentioned #PrajwalRai), error in the table name.
Old question, but maybe it helps:
sometimes you copy and paste text from a source that has a different character set ...
Type it over in sql-dev for instance and see if the error is gone
I was able to clear this error in an Oracle DB using Oracle SQL Developer by placing strings in single quotes instead of double quotes
OK, I am using SQL Plus and I am trying to view the table and one of the columns I was to view in lower case. This shold be very easy but for some reason it is not work. The code I am using is
SELECT CUSTOMER_NUM, CUSTOMER_ADD (LOWER)CUSTOMER_FIRST, (UPPER)CUSTOMER_LAST
FROM CUSTOMER;
The error I am getting is ORA-00904: "CUSTOMER_LAST": invalid identifier
Try lower(customer_first) and upper(customer_last)
lower and upper is function call, and you also have a missing coma after CUSTOMER_ADD. proper sql should be
SELECT CUSTOMER_NUM, CUSTOMER_ADD, LOWER(CUSTOMER_FIRST), UPPER(CUSTOMER_LAST) FROM CUSTOMER;