ora-00918

Oracle 12c - Ambiguous column in Insert Into Select Query, ORA-00918

陌路散爱 提交于 2020-07-23 02:05:42
问题 I am trying to execute multiple insert with single statement to achieve this I am using Insert into select statement. But I am facing when two columns have same value in insert. Error message that I am getting is ORA-00918: column ambiguously defined . Query INSERT INTO sample ( HOST, TOTAL_PING, TOTAL_UNAVAILABLE_PING ) SELECT * FROM ( SELECT 'FR3158-73-1', 82, 82 FROM DUAL UNION ALL SELECT 'FR3158-76-2', 80, 10 FROM DUAL ) Issue is there in first select statement where two values are 82 and

Oracle 12c - Ambiguous column in Insert Into Select Query, ORA-00918

荒凉一梦 提交于 2020-07-23 02:04:22
问题 I am trying to execute multiple insert with single statement to achieve this I am using Insert into select statement. But I am facing when two columns have same value in insert. Error message that I am getting is ORA-00918: column ambiguously defined . Query INSERT INTO sample ( HOST, TOTAL_PING, TOTAL_UNAVAILABLE_PING ) SELECT * FROM ( SELECT 'FR3158-73-1', 82, 82 FROM DUAL UNION ALL SELECT 'FR3158-76-2', 80, 10 FROM DUAL ) Issue is there in first select statement where two values are 82 and

Oracle 12c - Ambiguous column in Insert Into Select Query, ORA-00918

拟墨画扇 提交于 2020-07-23 02:03:08
问题 I am trying to execute multiple insert with single statement to achieve this I am using Insert into select statement. But I am facing when two columns have same value in insert. Error message that I am getting is ORA-00918: column ambiguously defined . Query INSERT INTO sample ( HOST, TOTAL_PING, TOTAL_UNAVAILABLE_PING ) SELECT * FROM ( SELECT 'FR3158-73-1', 82, 82 FROM DUAL UNION ALL SELECT 'FR3158-76-2', 80, 10 FROM DUAL ) Issue is there in first select statement where two values are 82 and

Column ambiguously defined in subquery using rownums

落花浮王杯 提交于 2019-12-11 05:26:53
问题 I have to execute a SQL made from some users and show its results. An example SQL could be this: SELECT t1.*, t2.* FROM table1 t1, table2 t2, where table1.id = table2.id This SQL works fine as it is, but I need to manually add pagination and show the rownum, so the SQL ends up like this. SELECT z.* FROM( SELECT y.*, ROWNUM rn FROM ( SELECT t1.*, t2.* FROM table1 t1, table2 t2, where table1.id = table2.id ) y WHERE ROWNUM <= 50) z WHERE rn > 0 This throws an exception: "ORA-00918: column

Mixing “USING” and “ON” in Oracle ANSI join

本小妞迷上赌 提交于 2019-12-09 03:01:27
问题 I wrote an Oracle SQL expression like this: SELECT ... FROM mc_current_view a JOIN account_master am USING (account_no) JOIN account_master am_loan ON (am.account_no = am_loan.parent_account_no) JOIN ml_client_account mca USING (account_no) When I try to run it, Oracle throws an error in the line with "ON" self-join saying: "ORA-25154: column part of USING clause cannot have qualifier". If I omit the "am" qualifier, it says: "ORA-00918: column ambiguously defined". What's the best way to

ORA 00918- Column ambiguosly defined error [duplicate]

£可爱£侵袭症+ 提交于 2019-12-02 13:12:41
This question already has an answer here: ORA-00918: column ambiguously defined in SELECT * 3 answers There are two tables in my Oracle database. First table is (customers)- customer_id Customer_name Customer_age Customer_address salary 103 Giriraj Rathi 22 Kolkata 12000 100 Subir Adhikari 22 Bolpur 10000 101 Rakesh Chatterjee 21 Tarkeshwar 8000 102 Jayanta Patra 20 Tarkeshwar 9000 104 Abhi Karmakar 22 Burdwan 8000 105 Mainak Manna 21 Burdwan 9000 106 Subho Gupta 20 Kolkata 10000 107 Aritra Das 23 Kolkata 7000 108 Pradip Paul 22 Kolkata 5000 109 Sourav Banerjee 22 Bolpur 9000 Second table is

Oracle UNION different columns

孤街醉人 提交于 2019-12-02 06:40:44
问题 I have two tables looking something like: TABLE_1 COL_A (int), COL_B (float), COL_C (float) TABLE_2 COL_A (int), COL_B (float) My query is using a UNION to put the results of these tables together, but where TABLE_2 doesn't have a COL_C, I'm looking to put something like '0'. But I just get a 'ORA-00918: column ambiguously defined' error How can I get around this? 回答1: You can try this SELECT COL_A, COL_B, COL_C FROM Table1 UNION SELECT COL_A, COL_B, 0 As COL_C FROM Table2 回答2: SELECT COL_A

Oracle UNION different columns

柔情痞子 提交于 2019-12-02 04:19:14
I have two tables looking something like: TABLE_1 COL_A (int), COL_B (float), COL_C (float) TABLE_2 COL_A (int), COL_B (float) My query is using a UNION to put the results of these tables together, but where TABLE_2 doesn't have a COL_C, I'm looking to put something like '0'. But I just get a 'ORA-00918: column ambiguously defined' error How can I get around this? You can try this SELECT COL_A, COL_B, COL_C FROM Table1 UNION SELECT COL_A, COL_B, 0 As COL_C FROM Table2 SELECT COL_A,COL_B,COL_C FROM TABLE_1 UNION SELECT COL_A,COL_B,'0' AS COL_C FROM TABLE_2 You may also be able to get away with

Why doesn't Oracle raise “ORA-00918: column ambiguously defined” for this query?

倾然丶 夕夏残阳落幕 提交于 2019-11-28 11:56:27
I've just come across a strange behaviour in Oracle where I would expect ORA-00918 to be raised, but isn't. Take this query, for example. SELECT * FROM USER_TABLES TAB JOIN USER_TRIGGERS TRG ON TRG.TABLE_NAME = TAB.TABLE_NAME WHERE STATUS = 'DISABLED' This query is notionally looking for the details of tables with disabled triggers, but please note that this is not the problem I'm trying to solve. The problem is not unique to this query, the data dictionary, views or tables; as far as I can tell it applies to any set of tables or views (from the two or three I've tried). Anyway, try to run

SQL: How to find duplicates based on two fields?

三世轮回 提交于 2019-11-28 07:28:38
I have rows in an Oracle database table which should be unique for a combination of two fields but the unique constrain is not set up on the table so I need to find all rows which violate the constraint myself using SQL. Unfortunately my meager SQL skills aren't up to the task. My table has three columns which are relevant: entity_id, station_id, and obs_year. For each row the combination of station_id and obs_year should be unique, and I want to find out if there are rows which violate this by flushing them out with an SQL query. I have tried the following SQL (suggested by this previous