Visit Our UNIX and Linux User Community


Help with Oracle SQL Developer - Subquery & Join will not work.


 
Thread Tools Search this Thread
Top Forums Programming Help with Oracle SQL Developer - Subquery & Join will not work.
# 1  
Old 06-10-2011
Help with Oracle SQL Developer - Subquery & Join will not work.

Greetings all,

Hopefully there is someone out there on this forum who can help with this Oracle SQL Developer issue I have.

Here is the code:

Code:
CREATE OR REPLACE VIEW
  SALES_OVER_30000_WITH_TOTAL
AS
  SELECT
    E.FIRST_NAME || ' ' || E.LAST_NAME AS EMPLOYEE_NAME,
    SUM(SO.TOTAL) AS TOTAL_SOLD
  FROM
    EMPLOYEE E
  LEFT OUTER JOIN 
    CUSTOMER C 
  ON
    C.SALESPERSON_ID = E.EMPLOYEE_ID
  LEFT OUTER JOIN 
    SALES_ORDER SO 
  ON
    SO.CUSTOMER_ID = C.CUSTOMER_ID
  GROUP BY EMPLOYEE_NAME
  HAVING SUM(SO.TOTAL) > 30000
;
SELECT
  EMPLOYEE_NAME,
  TOTAL_SOLD
FROM
  SALES_OVER_30000_WITH_TOTAL
ORDER BY EMPLOYEE_NAME DESC
;


The error being produced is:

Code:
Error at Command Line:17 Column:11
Error report:
SQL Error: ORA-00904: "EMPLOYEE_NAME": invalid identifier
00904. 00000 -  "%s: invalid identifier"
*Cause:    
*Action:

Which is..

Code:
GROUP BY EMPLOYEE_NAME

I have pretty much tried everything I simply cannot get this to work at all Smilie

Any suggestions would be greatly appreciated..

Thanks in advance
# 2  
Old 06-10-2011
Try:

Code:
[...]
group by
  E.FIRST_NAME || ' ' || E.LAST_NAME

This User Gave Thanks to radoulov For This Post:
# 3  
Old 06-10-2011
Hi, thanks for reply.

Was a standard syntax error in the end.

Can post new code if anyone is interested.

Previous Thread | Next Thread
Test Your Knowledge in Computers #146
Difficulty: Easy
In 1983, Richard Stallman announced the GNU (short for "GNU's Not Unix") project, to create a proprietary, commercial software Unix-like system.
True or False?

7 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Join, merge, fill NULL the void columns of multiples files like sql "LEFT JOIN" by using awk

Hello, This post is already here but want to do this with another way Merge multiples files with multiples duplicates keys by filling "NULL" the void columns for anothers joinning files file1.csv: 1|abc 1|def 2|ghi 2|jkl 3|mno 3|pqr file2.csv: 1|123|jojo 1|NULL|bibi... (2 Replies)
Discussion started by: yjacknewton
2 Replies

2. Programming

Sql developer how to upload the excel sheet in Oracle table

I have some records to be updated in oracle table. I am using sql developer tool. could any one tell me how to update those records in oracle table. I am having excel sheet with those records. (4 Replies)
Discussion started by: ramkumar15
4 Replies

3. Programming

SQL Developer JOINS / GROUP BY issue.

Am having a nightmare with a certain piece of code.. have tried almost everything and just cannot see what the issue is.. CREATE OR REPLACE VIEW TOP_EARNER_PER_LOCATION AS SELECT E.FIRST_NAME || ' ' || E.LAST_NAME AS EMPLOYEE_NAME, L.REGIONAL_GROUP AS REGIONAL_GROUP, ... (1 Reply)
Discussion started by: U_C_Dispatj
1 Replies

4. UNIX and Linux Applications

Alternative for slow SQL subquery

Hi -- I have the following SQL query in my UNIX shell script -- but the subquery in the second section is very slow. I know there must be a way to do this with a union or something which would be better. Can anyone offer an alternative to this query? Thanks. select count(*) from ... (2 Replies)
Discussion started by: whoknows
2 Replies

5. Shell Programming and Scripting

Oracle SQL Query & connect?

Hi I'm looking to query a table on a database and then iterate over the results in a loop. I believe this is the last part of my script that I need (after finding out threads for passing variables to other scripts and calling functions in other scripts). I've searched the forums but the best... (8 Replies)
Discussion started by: Dird
8 Replies

6. Programming

sql,multiple join,outer join issue

example sql: select a.a1,b.b1,c.c1,d.d1,e.e1 from a left outer join b on a.x=b.x left outer join c on b.y=c.y left outer join d on d.z=a.z inner join a.t=e.t I know how single outer or inner join works in sql. But I don't really understand when there are multiple of them. can... (0 Replies)
Discussion started by: robbiezr
0 Replies

7. Programming

Oracle: fixing an outer join on subquery...

I have a stored procedure that is failing. The current query behind it is: SELECT DISTINCT <many, many values> FROM table1 LEFT OUTER JOIN table2 ON (table2.key = (select max (table2.key) from table2 where table2.key = table1.key) or ... (0 Replies)
Discussion started by: Elric of Grans
0 Replies

Featured Tech Videos