ora-00904

Oracle show all employees with greater than average salary of their department

馋奶兔 提交于 2019-12-17 21:09:20
问题 I am writing a query to find employees who earn greater than the average salary within their department. I need to display the employee ID, salary, department id, and average salary of that department. I have a query that just almost works but it keeps giving me "ORA-00904: "AVG_SAL": invalid identifier" errors. Am I doing this correctly. Why am i getting this invalid identifier error? SELECT employee_id, salary, department_id, (SELECT ROUND(AVG(salary),2) FROM employees e_inner WHERE e_inner

Is it possible to query a comma separated column for a specific value?

孤人 提交于 2019-12-17 04:08:32
问题 I have (and don't own, so I can't change) a table with a layout similar to this. ID | CATEGORIES --------------- 1 | c1 2 | c2,c3 3 | c3,c2 4 | c3 5 | c4,c8,c5,c100 I need to return the rows that contain a specific category id. I starting by writing the queries with LIKE statements, because the values can be anywhere in the string SELECT id FROM table WHERE categories LIKE '%c2%'; Would return rows 2 and 3 SELECT id FROM table WHERE categories LIKE '%c3%' and categories LIKE '%c2%'; Would

Returned ref cursor not supported

元气小坏坏 提交于 2019-12-14 03:19:54
问题 I'm trying to make a chart in a database dashboard reporting software(Logi Info). I've got a PL SQL package that returns a ref cursor with multiple values but it seems the Logi Info does not support this and gives me an error ORA-00904: "DASHBOARD_PACKAGE"."GETSUMMARYDATA": invalid identifier . I think its either not supported or that my querty is wrong. This is my query: select dashboard_package.getSummaryData(1,sysdate) from dual Is that how to call a function that returns multiple values?

how to query a many to many for the absence of records using EF5

痞子三分冷 提交于 2019-12-13 03:18:27
问题 Assuming a pure many to many where the primary key is the composite of two foreign keys. For example "Employee Privileges" in Northwind has EmployeeID and PrivilegeID. This m2m obviously relates the Employees table to the Privilege table. I need to write a query with EF that returns all Employees that are NOT associated with a specified PrivilegeID, regardless of whether or not it is related to other PrivilegeIDs. I have an EF query that works for Sql Server using Except() but it doesn't work

using subquery instead of the tablename

会有一股神秘感。 提交于 2019-12-12 15:30:01
问题 Table Meta: ------------------------------------- type tab_name new tab_news sports tab_sps Table tab_news ------ id Table tab_sps ------------------- id xx Now I want to use SELECT id FROM (SELECT tab_name FROM Meta WHERE type = 'news'); But it does not work, any ideas? 回答1: SQL does not support a variable/etc for the table name -- the only means of supporting what you ask is by using dynamic SQL: FOR i IN (SELECT tab_name FROM META m WHERE m.type = ?) LOOP EXECUTE IMMEDIATE 'SELECT * FROM '

ora-00904 invalid identifier

烈酒焚心 提交于 2019-12-12 03:53:28
问题 I am having problem with my query... This one works: select name, bday, address, dbms_random.value(1, 100) as joker from employee order by joker asc But when I try to get what I want using either the 'where' and group/having clause, I am getting a ora-00904 (invalid identifier) ERROR.. e.g. select name, bday, address, dbms_random.value(1, 100) as joker from employee where joker>5 order by joker asc select name, bday, address, dbms_random.value(1, 100) as joker from employee group by name,

Oracle MERGE raise ORA-00904 error

给你一囗甜甜゛ 提交于 2019-12-12 01:46:51
问题 I am using merge command to insert a non-exist record into table. When I use simple insert command it works fine. If I use merge system always alert ORA-00904: "T"."GROUP_COMPANY_ID" invalid identifier. Once I change the ON condition to (1=1) to force be true then the merge command works fine. What the original merge statement goes to wrong? I am very sure the table was created without double quoted name so there is not case issue here. create table test ( create_date DATE not null, group

Intermittent ORA-00904: : invalid identifier

拜拜、爱过 提交于 2019-12-11 12:38:12
问题 Does anyone know what could be causing a fixed query (static final String) to work most of the time and then intermittently throw the following error: Inner cause: java.sql.SQLException: ORA-00904: : invalid identifier The query is being run through a JDBC connection. The curious thing here is that the identifier is empty, and of course that the query works intermittently. If I take the sql that has been logged out and run it through plsql developer it all works fine. Any ideas? Here's the

What's wrong with this SQL query?

我与影子孤独终老i 提交于 2019-12-11 12:37:21
问题 The following query returns "ORA-00904 error: SATIS: Invalid identifier." When I remove the line HAVING satis > 0 , it works. What should I do? SELECT donem, bolge_adi, sehir_tasra "1=Ş, 2=T", COUNT(DISTINCT mekankodu) "M.SAYISI", SUM(b2b_dagitim + b2b_transfer - b2b_iade) satis FROM mps_view2 WHERE donem IN ('200612','200712','200812','200912') AND (ob IS NOT NULL OR b2b_ob IS NOT NULL) GROUP BY donem, bolge_adi, sehir_tasra HAVING satis > 0 ORDER BY donem, bolge_adi, sehir_tasra 回答1: You

Oracle JOIN USING + Subquery : ora-00904 string: invalid identifier

泄露秘密 提交于 2019-12-10 15:54:31
问题 i m having a little syntax problem in my query (simplified) : select * from table1 t1 inner join table2 t2 using (pk1) inner join table3 t3 using (pk2) where not exists (select1 from table4 t4 where t4.pk1 = t1.pk1) By using the "using" keyword, oracle doesnt allow table identifier in front of the column name (eg : t1.pk1, only pk1 can be used) If i write : select * from table1 t1 inner join table2 t2 using (pk1) inner join table3 t3 using (pk2) where not exists (select1 from table4 t4 where