473,382 Members | 1,639 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,382 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 10143
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
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
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

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.