473,326 Members | 2,023 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Self join sub query syntax

I haven' been using SQL to long and I'm trying to create a query.
The syntax works in MS Access but when brought into oracle(Toad) I get a message at the ". AS" ORA-00905: missing keyword. I replaced the [ ]'s with ( ) after the INNER JOIN statement because it didn't line the joined table name when I used them.

SELECT APPS.CST_ITEM_COST_TYPE_V.Item_number, APPS.CST_ITEM_COST_TYPE_V.Description, APPS.CST_ITEM_COST_TYPE_V.Cost_Type, APPS.CST_ITEM_COST_TYPE_V.Item_Cost
FROM APPS.CST_ITEM_COST_TYPE_V INNER JOIN (SELECT Item_Number, Max(Cost_Type) AS MaxCost_Type FROM APPS.CST_ITEM_COST_TYPE_V GROUP BY Item_Number). AS q ON (APPS.CST_ITEM_COST_TYPE_V.Cost_Type = q.MaxCost_Type) AND (APPS.CST_ITEM_COST_TYPE_V.Item_number = q.Item_Number)

Can anyone help out.
Thanks,
Scott
Aug 26 '05 #1
1 10139
HI,
there is a dot where it should not be. I formatted your SQL using the online formatter at www.sqlinform.com

Expand|Select|Wrap|Line Numbers
  1. SELECT 
  2.     APPS.CST_ITEM_COST_TYPE_V.Item_number, 
  3.     APPS.CST_ITEM_COST_TYPE_V.Description, 
  4.     APPS.CST_ITEM_COST_TYPE_V.Cost_Type, 
  5.     APPS.CST_ITEM_COST_TYPE_V.Item_Cost 
  6. FROM 
  7.     APPS.CST_ITEM_COST_TYPE_V 
  8. INNER JOIN 
  9.     (SELECT 
  10.         Item_Number, 
  11.         Max(Cost_Type) AS MaxCost_Type 
  12.     FROM 
  13.         APPS.CST_ITEM_COST_TYPE_V 
  14.     GROUP BY 
  15.         Item_Number
  16.     )
  17.     [COLOR=Red]. AS q [/COLOR]
  18.     ON (APPS.CST_ITEM_COST_TYPE_V.Cost_Type    = q.MaxCost_Type) 
  19.     AND (APPS.CST_ITEM_COST_TYPE_V.Item_number = q.Item_Number)
Hope this helps
Guidomarcel
Sep 15 '05 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Good Man | last post by:
Hi there Yes, I've read about JOINs, albeit after coding for a couple of years already using queries like the following: "SELECT m.LastName, m.FirstName, o.Address FROM members m, offices o...
4
by: jbm05 | last post by:
Hi, I'm curious about the computational complexity of a query I have. The query contains multiple nested self left joins, starting with a simple select, then doing a self left join with the...
3
by: Ian Boyd | last post by:
i know nothing about DB2, but i'm sure this must be possible. i'm trying to get a client to create a view (which it turns out is called a "Logical" in DB2). The query needs a LEFT OUTER JOIN, but...
12
by: Phil Powell | last post by:
<cfquery name="getAll" datasource="#request.dsn#"> SELECT U.userID, U.fname, U.lname, U.phone, U.lastLoggedIn, U.choiceId, U.experience, T.label AS teamLabel, R.label AS roleLabel FROM User U...
4
by: Shahzad | last post by:
dear respected gurus, I would like to knew how to apply append,insert query for a self table where no primary keys issues. i do have problem say there are 5 rows of single record, this is data...
6
by: davegb | last post by:
I'm trying to create a self-join table to show the relationship between employee and supervisor. In another thread, I was advised to create a SupervisorID in the employee table, a separate...
14
by: Jim Andersen | last post by:
I have a problem with this standard employee-supervisor scenario For pictures: http://www.databasedev.co.uk/self-join_query.html I want to show all employees "belonging" to a specific...
3
by: Genalube | last post by:
All right I am new at access but why would my calculated fields in my query self destruct all of a sudden? I tested these expressions, saved the query and closed it. I reopened them and tested it. ...
14
by: cjakeman | last post by:
Hi, Solved a little mystery yesterday when I built a form that combined 2 tables with a 1:M relationship and relational integrity. All the correct data was visible on the form but, if I tried to...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.