How to convert my query to SQL Procedure

Hi all,
I am running an SQL Query in my page process to set few items on my page.
begin
declare
l_vc_arr2 APEX_APPLICATION_GLOBAL.VC_ARR2;
begin
IF APEX_APPLICATION.G_F01.COUNT = 0 THEN
RAISE_APPLICATION_ERROR(-20001, 'Please select a email template to edit!!!');
END IF;
IF APEX_APPLICATION.G_F01.COUNT > 1 THEN
RAISE_APPLICATION_ERROR(-20001, 'Please select a single email template to edit at a time!!!');
END IF;
FOR i in 1..APEX_APPLICATION.G_F01.count
LOOP
l_vc_arr2 := APEX_UTIL.STRING_TO_TABLE(APEX_APPLICATION.G_F01(i),'$');
:P32_SUBJECT := l_vc_arr2(1);
:P32_TYPE := l_vc_arr2(2);
:P32_BODY := l_vc_arr2(3);
END LOOP;
end;
end;
It is running perfectly fine. Now i want to convert this query into custom procedure. I am writing follwing code to create SQL Procedure,
create or replace
procedure Edit_EmailTemplate as
begin
declare
l_vc_arr2 APEX_APPLICATION_GLOBAL.VC_ARR2;
begin
IF APEX_APPLICATION.G_F01.COUNT = 0 THEN
RAISE_APPLICATION_ERROR(-20001, 'Please select a email template to edit!!!');
END IF;
IF APEX_APPLICATION.G_F01.COUNT > 1 THEN
RAISE_APPLICATION_ERROR(-20001, 'Please select a single email template to edit at a time!!!');
END IF;
FOR i in 1..APEX_APPLICATION.G_F01.count
LOOP
l_vc_arr2 := APEX_UTIL.STRING_TO_TABLE(APEX_APPLICATION.G_F01(i),'$');
v(P32_SUBJECT) := l_vc_arr2(1);
v(P32_TYPE) := l_vc_arr2(2);
v(P32_BODY) := l_vc_arr2(3);
END LOOP;
end;
end;
but it is not getting compiled. Do anyone know what the problem is???
With Regards,
Sunil Bhatia

hey thanks,
but my problem is not of creating,
it has been created and i can see it in sql browser. but it is not getting compiled
it is returning with the following error
Compilation failed,line 18 (13:22:08)
PLS-00306: wrong number or types of arguments in call to 'V'Compilation failed,line 18 (13:22:08)
PL/SQL: Statement ignoredCompilation failed,line 19 (13:22:08)
PLS-00306: wrong number or types of arguments in call to 'V'Compilation failed,line 19 (13:22:08)
PL/SQL: Statement ignoredCompilation failed,line 20 (13:22:08)
PLS-00306: wrong number or types of arguments in call to 'V'Compilation failed,line 20 (13:22:08)
PL/SQL: Statement ignored
my statement is
create or replace
procedure Edit_EmailTemplate as
begin
declare
l_vc_arr2 APEX_APPLICATION_GLOBAL.VC_ARR2;
begin
IF APEX_APPLICATION.G_F01.COUNT = 0 THEN
RAISE_APPLICATION_ERROR(-20001, 'Please select a email template to edit!!!');
END IF;
IF APEX_APPLICATION.G_F01.COUNT > 1 THEN
RAISE_APPLICATION_ERROR(-20001, 'Please select a single email template to edit at a time!!!');
END IF;
FOR i in 1..APEX_APPLICATION.G_F01.count
LOOP
l_vc_arr2 := APEX_UTIL.STRING_TO_TABLE(APEX_APPLICATION.G_F01(i),'$');
v('P32_SUBJECT') := l_vc_arr2(1);
v('P32_TYPE') := l_vc_arr2(2);
v('P32_BODY') := l_vc_arr2(3);
END LOOP;
end;
end;

Similar Messages

  • How to convert MDX query to SQL

    Hi everyone,
    can you please suggest me, how to convert the below mdx query to sql query. can you please tell me what it is doing?
    CREATE MEMBER CURRENTCUBE.[Measures].[calculation]
     AS IIF(([Measures].[Clear Call Count],[Trouble Code].[Is Battery].&[Battery T-Code],[Service Provider].[Is Towmark].&[Towmark],[Provider Technician].[Is Towmark].&[Towmark]) = 0, NULL,
    ([Measures].[ Total Shipped],[Service Provider].[Is Towmark].&[Towmark],[Provider Technician].[Is Towmark].&[Towmark])/
    ([Measures].[Clear Call Count],[Trouble Code].[Is Battery].&[Battery T-Code],[Service Provider].[Is Towmark].&[Towmark],[Provider Technician].[Is Towmark].&[Towmark])),
    FORMAT_STRING = "Percent",
    VISIBLE = 1 ,  ASSOCIATED_MEASURE_GROUP = 'Sale'; 
    Thanks
    Vishu

    Hi Vishu,
    As Olaf said, this is a calculated member which used in MDX script in your cube, we cannot execute it in SQL Server Management Studio directly. Here are some document about calculated members and MDX script for your reference.
    Defining Calculated Members
    MDX Scripting Fundamentals (Analysis Services)
    Regards,
    Charlie Liao
    TechNet Community Support

  • Converting MDX query into SQL Server 2008

    We have MDX query based OLAP CUbes.
    To reduce MDX based dependenies, we have to convert MDX based cube to sql server 2008 based queries.
    For this I need expert advise to convert below query to sql server 2008 based query :
    CREATE MEMBER CURRENTCUBE.Measures.[Ack Lost]
                        AS 'Sum(PeriodsToDate([Time].[Year], [Time].CurrentMember ), [Measures].[Lost])',
                        FORMAT_STRING = "#,#",
                        VISIBLE = 1;

    Hi Sachin,
    According to your description, you need to convert the MDX query to T-SQL query, right?
    Your MDX query is calculated measure that return the total value from the first sibling and ending with the given member. In T-SQL query we can use the query as Yogisha provided to achieve the same requirement. Now you need to a tool to convert all the MDX
    related SSAS cube queries to MS SQL Server 2008 based queries.
    Although MDX has some similarities with T-SQL these languages are in many ways different. Beginning to learn and comprehend SQL Server Analysis Services (SSAS) MDX queries can be difficult after one has spent years writing queries in T-SQL. Currently, there
    is no such a tool to convert a MDX query to T-SQL query since the structure difference between MDX and T-SQL. So you need to convert them manually, please refer to the links below to see the details.
    http://www.mssqltips.com/sqlservertip/2916/comparison-of-queries-written-in-tsql-and-sql-server-mdx/
    https://sqlmate.wordpress.com/2013/11/12/t-sql-vs-mdx-2/
    http://technet.microsoft.com/en-us/library/aa216779(v=sql.80).aspx
    Regards,
    Charlie Liao
    TechNet Community Support

  • How to write exact query from sql to oracle?

    Hi all,
    hope doing well,
    sir i am using one query in sql that is
    declare @earlyleavers varchar(max), @earlyleavers1 int
    select @earlyleavers1 = DATEDIFF(Minute,'1900/01/01 10:00:00.000','1900/01/01 11:00:00.000')
    select @earlyleavers = CONVERT(char(8),DATEADD(n,@earlyleavers1,0),108)
    print @earlyleavers
    and i am getting the result like this
    01:00:00
    how to get the same result in oracle
    please help me.
    thanks in advance.

    952646 wrote:
    sir i need result in this format 01:00 not in 1 format.The name is Billy and not "sir". :-)
    Is "01:00" a string format or an elapsed time format?
    The number that the above code returns is decimal hours. So a number value of 1.5 means 1h30m or 1:30 or however you need to render that.
    And that is the question. Is this a rendering issue? Must the result be rendered in a specific format?
    If so, then this is not a SQL or PL/SQL issue. The server returning decimal hours is acceptable. The client (e.g. C#/Java code) needs to decide how to format and render this meaningful value. Keep in mind that if the sever code returns "1.30" or "1:30" for example, these are string/text data and pretty much meaningless. And it does not make sense for server code to return meaningless text strings to the client.
    If the client expects a duration and not a numeric data type, then the server code should return a value of the INTERVAL DAY TO SECOND data type.
    This data type specifically exists to contain duration values between to dates or times.
    In this case, the server code will expect the host (C#/Java) variable to be of data type INTERVAL DAY TO SECOND. The server code will look something as follows:
    SQL> declare
      2          earlyleavers    interval day to second;
      3  begin
      4          earlyleavers := NumToDSinterval(
      5                                  (to_date('1900/01/01 11:00:00','yyyy/mm/dd hh24:mi:ss') -
      6                                  to_date('1900/01/01 10:00:00','yyyy/mm/dd hh24:mi:ss') ) * 24,
      7                                  'hour'
      8                          );
      9 
    10          dbms_output.put_line( to_char(earlyleavers) );
    11  end;
    12  /
    +00 01:00:00.000000
    PL/SQL procedure successfully completed.
    SQL>An interval-to-string conversion function is used (with default formatting) to "print" the interval value via DBMS_OUTPUT. The default format includes days and a sign to indicate a positive or negative interval. Look at the SQL Reference manual for the format masks that can be used.
    The important thing is to treat data values correctly using the most appropriate type. And intervals should either be a decimal day/hour/minute numeric type, or an actual interval type.

  • How to get exact query of sql in oracle?

    Hi all,
    Hope doing well,
    sir i was using one query of sql that is here:
    Declare @nshiftmax datetime
    set @nshiftmax=convert(time,DATEADD(N,1439,0))
    print @nshiftmax
    so it is retreiving the result 1/1/1900 11:59 p.m
    and one more query is there
    Declare @nshiftmax datetime
    set @nshiftmax=convert(time,DATEADD(N,0,0))
    print @nshiftmax
    so it is retreiving the result 1/1/1900 12:00 a.m
    how to same result in oracle query.
    thanks in advance.

    952646 wrote:
    Hi all,
    Hope doing well,
    sir i was using one query of sql that is here:
    You mean you have these statements in SQL Server?
    Please remember that SQL is an access language for relational databases. It is used by all of the major rdbms products. "SQL Server" is the name of Microsoft's rdbms product. Do not let Microsoft's marketing flaks lull you into thinking SQL = SQL Server.
    Declare @nshiftmax datetime
    set @nshiftmax=convert(time,DATEADD(N,1439,0))
    print @nshiftmax
    so it is retreiving the result 1/1/1900 11:59 p.m
    and one more query is there
    Declare @nshiftmax datetime
    set @nshiftmax=convert(time,DATEADD(N,0,0))
    print @nshiftmax
    so it is retreiving the result 1/1/1900 12:00 a.m
    how to same result in oracle query.
    thanks in advance.

  • Converting Oracle query to Sql Server with date manipulation

    The following SSIS statement works great in Oracle, and it parses successfully in the "Sql Task" window. In Oracle it returns
    this result:
    FROM_DT              THRU_DT
    16-Jan-2014      23-Jan-2014
    select
    case
    when to_char(to_date(sysdate,'dd-mon-yyyy'),'dd') <=7 then to_date('24'||to_char(add_months(sysdate,-1),'mmyyyy'),'ddmmyyyy')
    when to_char(to_date(sysdate,'dd-mon-yyyy'),'dd') <=15 then to_date('01'||to_char(sysdate,'mmyyyy'),'ddmmyyyy')
    when to_char(to_date(sysdate,'dd-mon-yyyy'),'dd') <=23 then to_date('08'||to_char(sysdate,'mmyyyy'),'ddmmyyyy')
    else to_date('16'||to_char(sysdate,'mmyyyy'),'ddmmyyyy')
    end as from_dt,
    case
    when to_char(to_date(sysdate,'dd-mon-yyyy'),'dd') <=7 then trunc(last_day(add_months(sysdate,-1)))
    when to_char(to_date(sysdate,'dd-mon-yyyy'),'dd') <=15 then to_date('07'||to_char(sysdate,'mmyyyy'),'ddmmyyyy')
    when to_char(to_date(sysdate,'dd-mon-yyyy'),'dd') <=23 then to_date('15'||to_char(sysdate,'mmyyyy'),'ddmmyyyy')
    else to_date('23'||to_char(sysdate,'mmyyyy'),'ddmmyyyy')
    end as thru_dt
    from sys.dual
    How can I convert this to Sql Server ?

    >>You mean you get the data from Oracle and tries to insert it into SQL Server?
    - no, sorry, I want to convert the syntax to Sql Server
    >>Are
    you running the query in OLEDB provider connected to the Oracle's database?
    - yes, this works fine now (after fixing this redundancy:
    to_char(to_date(sysdate,'dd-mon-yyyy'),'dd')change toto_char(sysdate,'dd')

  • How to convert Oracle database to Sql server Database

    Hi All,
    I have one database made in the Oracle 8i, i want to convert that database to Sql Server Database,
    Can anyone please give me the step by step process to do this conversion.
    Regards
    Ramesh Jha

    Try using the DTS (data transformation services) services of SQL Server 2000
    DTS is based on an OLE DB architecture that allows you to copy and transform data from a variety of data sources. For example: Oracle directly, using native OLE DB providers.
    Alternatively, you could follow the following broad steps for data migration (assuming you are retaining the same table structures in SQL Server, and that you are talking about SQL Server 2000).
    1. Get the CREATE scripts corresponding to each Oracle table / view / index. These can be reverse engineered from the database using a tool.
    2. Map Oracle datatypes to SQL server datatypes e.g: date maps to datetime/smalldatetime, numeric maps to one of int, bigint, smallint, etc depending on the range of values in the CREATE scripts.
    3. Indexes in SQL Server are of two types: Clustered / non-clustered. There can only be one clustered index on each table.
    4. Converting procedures and triggers will have to be line by line, since SQL Server uses a proprietary T-SQL instead of ORacle's PL/SQL
    I have yet to see a really good tool to do this migration, but it is possible to write a PL/SQL procedure / Pro*C program to automate the script creation for creating tables in the SQL Server database.
    For the actual data import into SQL Server, export the Oracle data table by table into flat files, and then use the import wizard of SQL Server enterprise manager

  • How to Set arguments to PL-SQL Procedure schedule to run from OEM.

    Hi All,
    OEM Config Details is as follows
    Oracle (R) Enterprise Manager Ver 9.2.0.1.0
    I created a job which is scheduled to run a PL-SQL Procedure. The procedure should accept two arguments as follows.
    BEGIN
    FLSTG.PROC_DELETE_DATA (ARG1,ARG2);
    END;
    Arg1 is of type Varchar2 & Arg2 is of type Date
    How should i set arguments for the procedure?
    Can someone please help me?
    Thanks in Advance.
    Regards,
    Vidyanand

    The only problem is when writing an ODI procedure using the Oracle Technology in ODI Designer, ODI asks for the Schema.
    If I do not assign a value to the schema field when I run my ODI procedure I get the error message :
    java.lang.Exception: Internal error: object ConnectConnection
    ColConnectId:null
    ColContextCode:CTX_SRC
    ColConName:null
    ColIndCommit:null
    ColIsolLevel:null
    ColLschemaName:null
    ColPlanComp:null
    ColTechIntName:null
    DefConnectId:null
    DefContextCode:CTX_SRC
    DefConName:null
    DefIndCommit:null
    DefIsolLevel:null
    DefLschemaName:null
    DefPlanComp:null
    DefTechIntName:ORACLE
    ExeChannel:J
    IndErr:0
    IndLogMethod:null
    IndLogNb:null
    LogLevDet:3
    Nno:1
    OrdTrt:0
    ScenTaskNo:1
    SessNo:4152001
    TaskName1:Traitement
    TaskName2:CNT_SRC_ALL
    TaskName3:DROP COUNT_ROWS

  • How to convert Access query to Oracle?

    I am trying to convert this query into an Oracle 8i query: -
    SELECT *
    FROM EMPLOYEE
    LEFT JOIN ATTENDANCE ON EMPLOYEE.EMPID = ATTENDANCE.EMPID
    WHERE ATTENDANCE.COL1="#"
    AND ATTENDANCE.COL2>=#1/1/2007#
    AND ATTENDANCE.COL2<Now()
    GROUP BY EMPLOYEE.EMPID, EMPLOYEE.EMPNO;
    How do I put the above query in plain Oracle join operator (+) notation? Thanks for the help.

    Hi,
    Let us take a look at the solution you had suggested -
    EMPLOYEE.EMPID = ATTENDANCE.EMPID (+)
    AND ATTENDANCE.COL1="#"
    AND ATTENDANCE.COL2 >= TO_DATE ('1/1/2007','dd/mm/yyyy')
    AND ATTENDANCE.COL2< SYSDATE;
    Since we are outer joining ATTENDANCE but not using the (+) operator in the later filter conditions; it will still be a normal join i.e. it will not outer join on ATTENDANCE. That is my question.

  • How to re-use a PL/SQL procedure on 2 different logical schemas

    Hi all,
    I need to run the same Oracle PL/SQL procedure on 2 databases (source/target).
    How can I re-use the code without having to duplicate the codeof the procedure because as it is a Oracle procedure, I need to declare the logical schema ?
    ==> does the procedure need to be re-written in Jython ?
    Thanks to your all .
    Nb my procedure code :
    CREATE TABLE COUNT_ROWS AS SELECT TABLE_NAME , NUM_ROWS FROM DBA_TABLES WHERE OWNER_NAME = 'SYSADM'
    Edited by: Meapri on Mar 18, 2011 3:37 AM

    The only problem is when writing an ODI procedure using the Oracle Technology in ODI Designer, ODI asks for the Schema.
    If I do not assign a value to the schema field when I run my ODI procedure I get the error message :
    java.lang.Exception: Internal error: object ConnectConnection
    ColConnectId:null
    ColContextCode:CTX_SRC
    ColConName:null
    ColIndCommit:null
    ColIsolLevel:null
    ColLschemaName:null
    ColPlanComp:null
    ColTechIntName:null
    DefConnectId:null
    DefContextCode:CTX_SRC
    DefConName:null
    DefIndCommit:null
    DefIsolLevel:null
    DefLschemaName:null
    DefPlanComp:null
    DefTechIntName:ORACLE
    ExeChannel:J
    IndErr:0
    IndLogMethod:null
    IndLogNb:null
    LogLevDet:3
    Nno:1
    OrdTrt:0
    ScenTaskNo:1
    SessNo:4152001
    TaskName1:Traitement
    TaskName2:CNT_SRC_ALL
    TaskName3:DROP COUNT_ROWS

  • How to Start report from pl sql procedure

    I need to create a procedure which runs report and email report output to specified email adress.
    I don't know how to start report from pl/sql. Any help will be appreciated.

    I want to start oracle report from plsql procedure. Is there any OS system command I can use or any other method? My database is installed on windows 2000 machine.

  • How to extract row_id from PL/SQL procedure and assign that to batch script

    Hello Team,
    I am stuck with a requirement, wherein I am running a batch script and within the batch script I am calling a procedure which inserts a record in a table (Including a column named l_id).
    I need this generated l_id to be passed on as a variable to batch script after PL/SQL procedure completion. So that I can refer this same l_id to update the same record in the table again in the same batch script in the later part.
    Looking for some suggestions!!!!
    Thanks
    -Vj.

    789153 wrote:
    I am stuck with a requirement, wherein I am running a batch script and within the batch script I am calling a procedure which inserts a record in a table (Including a column named l_id). Operating system? Scripting language or command shell used?
    I need this generated l_id to be passed on as a variable to batch script after PL/SQL procedure completion. So that I can refer this same l_id to update the same record in the table again in the same batch script in the later part.
    Looking for some suggestions!!!!Don't do this using batch scripts. Batch scripts are very much inferior compared to stored PL/SQL code when it comes to managing databases processes and performing data crunching.
    Why can't this be written entirely in PL/SQL? And execution managed from either DBMS_JOB or DBMS_SCHEDULER ? And before answering that, consider the following:
    - what is the superior language, PL/SQL or shell script?
    - what provides tighter integration with the database, PL/SQL or shell script?
    - what provides proper security and access control, PL/SQL or shell script?
    As you can call SQL*Plus from a shell script to run PL/SQL, you can call a shell script from PL/SQL instead to run external commands and processes.
    Use the right tool for the job. And shell scripting is an excellent tool - but only when correctly used. Are you using it correctly? I strongly doubt that...

  • How to convert XML content into SQL INSERT statements

    Hi all,
    I'm very new to XML. Forgive me if I don't use technical XML terms. :-)
    We are planning to convert SQL queries into XML format using a third party tool.
    After that we have to read the XML files and use the tokens to insert into custom tables.
    So, basically we have to create INSERT statements using the data stored in the XML file.
    How do we go about reading / parsing the XML file in Java?
    Pls help!
    Regards,
    Sam

    This is the requirement with an example.
    eg. if the following SQL query is fed into the 3rd party system,
    select last_name,job_id,salary from employees a, deptno b
    where a.deptno = b.deptno
    the output would be,
    <?xml version="1.0" ?>
    <sqlscript dbvendor="MSSQL">
    <fullselectstmt nestlevel="0">
    <subselectstmt><selectclause><fieldlist>
    <field><fieldname>
    <attr>
    <sourcetoken toketype="" dbobjtype="field">last_name</sourcetoken>
    </attr>
    </fieldname>
    </field>
    <field><fieldname>
    <attr>
    <sourcetoken toketype="" dbobjtype="field">job_id</sourcetoken>
    </attr>
    </fieldname>
    </field>
    <field><fieldname>
    <attr>
    <sourcetoken toketype="" dbobjtype="field">salary</sourcetoken>
    </attr>
    </fieldname>
    </field>
    </fieldlist></selectclause>
    <fromclause><joinlist><join nestlevel="0">
    <lztable><simpletable><attr>
    <sourcetoken toketype="" dbobjtype="table">employees</sourcetoken>
    </attr><aliasclause withas="false"><sourcetoken toketype="" dbobjtype="table alias">a</sourcetoken></aliasclause></simpletable></lztable></join><join nestlevel="0">
    <lztable><simpletable><attr>
    <sourcetoken toketype="" dbobjtype="table">deptno</sourcetoken>
    </attr><aliasclause withas="false"><sourcetoken toketype="" dbobjtype="table alias">b</sourcetoken></aliasclause></simpletable></lztable></join></joinlist></fromclause>
    <whereclause><expression exprtype="Expr_Comparison" exproop="="><attr>
    <sourcetoken toketype="" dbobjtype="table alias">a</sourcetoken>
    <sourcetoken toketype="" dbobjtype="unknown">.</sourcetoken>
    <sourcetoken toketype="" dbobjtype="field">deptno</sourcetoken>
    </attr><attr>
    <sourcetoken toketype="" dbobjtype="table alias">b</sourcetoken>
    <sourcetoken toketype="" dbobjtype="unknown">.</sourcetoken>
    <sourcetoken toketype="" dbobjtype="field">deptno</sourcetoken>
    </attr></expression>
    </whereclause></subselectstmt></fullselectstmt>
    </sqlscript>
    So, using the output file, the list of columns (under token "field") last_name,job_id and salary should be inserted into LIST_COLUMNS table. So 3 INSERT statements should be created for 3 columns.
    The list of tables (under token "table") employees and dept should be inserted into LIST_TABLES table. So 2 INSERT statements should be created for the 2 tables.
    Regards,
    Sam

  • How to connect and query the sql database in mobile application

    Hello,
    Can any one say how to connect the sql database from the j2me application.
    I have got some info that only through servlet or jsp only we can connect the database and from their we should get the info or query in mobile application.
    Is it true? and can i have any sample codes or white paper or guildlines.
    It would be more useful form my project.
    Thanks in advance.
    regards,
    sara

    Hi David,
    According to your description, when you add Windows Azure Mobile Services to a Window Phone 8 app, then store app data in the new mobile service. I recommend you post the related question on the Windows Azure Mobile Services Forums at
    http://social.msdn.microsoft.com/Forums/en-US/home?forum=azuremobile .It is appropriate and more experts will assist you.
    In addition, there are the details about creating a Windows Phone app connected to your mobile service.
    http://www.windowsazure.com/en-us/develop/mobile/tutorials/get-started-wp8/
    http://www.windowsazure.com/en-us/develop/mobile/tutorials/get-started-with-data-wp8/
    Thanks,
    Sofiya Li
    Sofiya Li
    TechNet Community Support

  • How to convert nested query to join

    Hello All
    I wrote a query, at first i find the name of the highest mountain,then find its provience and then list of mountains in this porvience.please help me to convert it to a join or generally a standard form.thank you in advance.
    select mountain from geo_mountain where province=
    (select province from geo_mountain where mountain=(select name from mountain where height=(select max(height) from mountain)))
    mountain: name,height,...
    geo_mountain: mountain,country,province

    Hi,
    Welcome to the forum!
    Here's one way to do it:
    WITH     got_r_num     AS
         SELECT     name
         ,     RANK () OVER (ORDER BY  height  DESC)     AS r_num
         FROM     mountain
    SELECT  p.mountain
    FROM      got_r_num     r
    JOIN     geo_mountain  n      ON  n.name       = r.name
    JOIN     geo_mountain  p  ON  p.proivince  = n.province
    WHERE     r.r_num        = 1
    ;A slightly different approach, closer to what you posted, involves a 4-way join:
    (1) In a sub-query (let's call it got_max_height) find just the maximum height from mountain
    (2) Join got_max_height to mountain, to get all mountains with that height. (There may be a tie)
    (3) Join this to geo_mountain to get the province(s)
    (4) Join this to another copy of geo_mountain to get all mountains in the same province(s). This step is just like the self-join in the query I posted.
    I hope this answers your question.
    If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all the tables involved, and the results you want from that data.
    Point out where the query above is producing the wrong results, and explain, using specific examples, how you get the right results from the given data in those places.
    Always say what version of Oracle you're using (e.g. 11.2.0.2.0).
    See the forum FAQ {message:id=9360002}

Maybe you are looking for

  • Sync Highlight in PDF file between Mac and iPad

    I need to read hundreds of PDF articles/books(downloaded from non-apple sources) on Mac(OS X 10.9.5) and iPad(iOS 7.2). Problem is that marking/highlight done in PDF file in iPad using Adobe reader/Foxit/TinyPDF or any other PDF reader can not be syn

  • Org Structure Audit Trail?

    Is there a standard report or method of viewing changes made to the organization structure in HR? thanks in advance.

  • Why can't i import photos from a different user account?

    Why when i import photos to iphoto from my user account it works fine. If i try importing them from the other user account it the photo it shows the event folder in the events page but when you go into it there are no photos, and when you close the a

  • Zen Micro - display says no license?

    My daughters Zen Micro will not access any of the songs. She gets a message telling her she does not have a license to play the tracks. They were downloaded from Napster-to-go, and our subscription is current. Prior to the message, the Micro consiste

  • CUCM on ISR E-Series

    Does anyone know if it possible to run CUCM on a ISR E-Series server?  I would make for low cost subscriber at a remote site?