Solve the query

Hi all,
We r working on SQL queries unable to solve teh below query.
"Display the names of the highest paid programmers for each language"
The table relating to the query is given below.
PNAME DOB DOJ S PROF1 PROF2 SALARY
anand 21-APR-66 21-APR-92 m pascal basic 3200
altaf 02-JUL-64 13-NOV-90 m clipper cobol 2800
juliana 31-JAN-68 21-APR-90 f cobol dbase 3000
kamala 30-OCT-68 02-JAN-92 f c dbase 2900
mary 24-JUN-70 01-FEB-91 f c++ oracle 4500
nelson 11-SEP-65 11-OCT-89 m cobol dbase 2500
partick 10-NOV-65 21-APR-90 m pascal clipper 2800
qadir 31-AUG-65 21-APR-91 m assembly c 3000
ramesh 03-MAY-67 28-FEB-91 m pascal dbase 3200
resecca 01-JAN-67 28-DEC-90 m basic cobol 2500
remitha 19-APR-70 20-APR-93 f c assembly 3600
revathi 02-DEC-69 02-JAN-92 f pascal basic 3700
vijaya 14-DEC-65 02-MAY-92 f foxpro c 3500
Thanking in advance.
Milind.

you can achieve it using analytics.
SQL> create table dummy(ename varchar2(32), salary number, language varchar2(32))
  2  /
Table created.
SQL>
SQL> insert into dummy values('Scott', 5000, 'C')
  2  /
1 row created.
SQL> insert into dummy values('Tiger', 4000, 'C')
  2  /
1 row created.
SQL> insert into dummy values('Mark', 5000, 'Java')
  2  /
1 row created.
SQL> insert into dummy values('Smith', 4000, 'Java')
  2  /
1 row created.
SQL> insert into dummy values('White', 3000, 'Oracle')
  2  /
1 row created.
SQL> insert into dummy values('Blake', 25000, 'C++')
  2  /
1 row created.
SQL>
SQL> set linesize 1000
SQL> column ename format a32
SQL> column salary format 9999999
SQL> column language a32
SP2-0158: unknown COLUMN option "a32"
SQL>
SQL> select * from (
  2  select ename, salary , language
  3       , row_number() over (partition by language order by salary desc ) high_sal
  4  from dummy)
  5  where high_sal=1
  6  /
ENAME                              SALARY LANGUAGE                           HIGH_SAL                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
Scott                                5000 C                                         1                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
Blake                               25000 C++                                       1                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
Mark                                 5000 Java                                      1                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
White                                3000 Oracle                                    1                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
SQL> select ename, salary, language from (
  2  select ename, salary , language
  3       , row_number() over (partition by language order by salary desc ) high_sal
  4  from dummy)
  5  where high_sal=1
  6  /
ENAME                              SALARY LANGUAGE                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
Scott                                5000 C                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            
Blake                               25000 C++                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          
Mark                                 5000 Java                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
White                                3000 Oracle                                                                                                             

Similar Messages

  • Please solve the query

    Hi,
    I have a query which requires me to find the language that is known by only on programmer
    PNAME PROF1 PROF2
    anand pascal basic
    altaf clipper cobol
    juliana cobol dbase
    kamala c dbase
    mary c++ oracle
    nelson cobol dbase
    partick pascal clipper
    qadir assembly c
    ramesh pascal dbase
    resecca basic cobol
    remitha c assembly
    revathi pascal basic
    vijaya foxpro c
    The answer to this query is
    C++
    foxpro
    oracle.

    Hi APC,
    SQL> SELECT prof, p_cnt FROM(
      2  SELECT prof1 AS prof, count(pname) AS p_cnt
      3  FROM user_lang
      4  GROUP BY prof1
      5  UNION
      6  SELECT prof2 , count(pname)
      7  FROM user_lang
      8  GROUP BY prof2 )
      9  WHERE p_cnt = 1;
    PROF                      P_CNT
    assembly                      1
    basic                         1
    c++                           1
    clipper                       1
    foxpro                        1
    oracle                        1
    6 rows selected.You have to count AFTER the union... ;-)
    Regards,
    Gerd

  • Please help me solve the query

    CREATE TABLE SPONSER_UPDATION
    MEMBER VARCHAR2(12),
    SPONSER VARCHAR2(10),
    POINT NUMBER(10)
    MEMBER     SPONSER     POINT
    a     AS     10
    b     a     10
    c     b     10
    d     c     10
    e     d     10
    f     e     10
    i want a query or trigger on updating a single row all the row corresponding to it also gets updated example if i update a row with member f then its sponser e should also be updated and if sponser is is updatd then its sponser d should also be updated and if d is updated its spnser c should also be updated untill the last one through a single query
    i have written the trigger
    CREATE OR REPLACE TRIGGER points_updation
    AFTER UPDATE
    ON sponser_updation
    FOR EACH ROW
    DECLARE
    v_username varchar2(10);
    BEGIN
    update sponser_updation
    set
    point=point+10
    where
    :new.member=:old.sponser;
    END;
    after updation of any row error message is comming
    ORA-04098: trigger 'INVENT.SPONSER_UPDATION1' is invalid and failed re-validation
    thanks & Regards,
    anuj kumar singh!

    You can not insert, delete or update into this trigger type.
    try this:
    CREATE OR REPLACE TRIGGER points_updation BEFORE UPDATE ON sponser_updation FOR EACH ROW
    BEGIN
    if :new.member = :old.sponser then
    :new.point:=:new.point+10;
    end if;
    END;

  • Solve the Query plz

    I am having employee table like
    empId ename mgrid (empid id primary key,MgrId is foreign key ref of empId)
    1 a null
    2 b 1
    3 c 1
    4 d 2
    5 e 2
    6 f 3
    i need the out put like
    empId ename mgrid level
    1 a null 1
    2 b 1 2
    3 c 1 2
    4 d 2 3
    5 e 2 3
    6 f 3 3

    SELECT    empId, ename, mgrid ,level
          FROM employees
    START WITH mgrid IS NULL
    CONNECT BY prior empId = mgrid;
    SQL> SELECT     empno, ename, mgr, LEVEL
      2        FROM emp_test
      3  START WITH mgr IS NULL
      4  CONNECT BY prior empno = mgr;
         EMPNO ENAME             MGR      LEVEL
          7839 KING                           1
          7566 JONES            7839          2
          7788 SCOTT            7566          3
          7902 FORD             7566          3
          7698 BLAKE            7839          2
          7699 DAVID            7839          2
          7782 CLARK            7839          2
    7 ligne(s) sélectionnée(s).
    SQL> select * from emp_test;
         EMPNO ENAME      JOB              MGR HIREDATE          SAL       COMM     DEPTNO
          7698 BLAKE      MANAGER         7839 1981-05-01      20000                    30
          7566 JONES      MANAGER         7839 1981-04-02       5950                    20
          7699 DAVID      MANAGER         7839 1981-05-01      20000                    30
          7782 CLARK      MANAGER         7839 1981-06-09      20000                    10
          7839 KING       PRESIDENT            1981-11-17      10000                    10
          7902 FORD       ANALYST         7566 1981-12-03       6000                    20
          7788 SCOTT      ANALYST         7566 2087-04-19       6000                    20
    7 ligne(s) sélectionnée(s).
    SQL>

  • Please solve the query in a single query

    1. display names of scott's collegue who earn more than scott
    using the emp table of scott schema

    As it's homework, we could always post you a really poor example of code like this:
    SQL> ed
    Wrote file afiedt.buf
      1  select *
      2  from emp
      3  where (1,empno) in (
      4                    select case when sal > (select sal from emp where ename = 'SCOTT') then 1 else 0 end as flag, empno
      5                    from emp
      6*                  )
    SQL> /
         EMPNO ENAME      JOB              MGR HIREDATE                   SAL       COMM     DEPTNO
          7839 KING       PRESIDENT            17/11/1981 00:00:00       5000                    10But it would be better if you gave us an example of what you have done yourself, before we show you where you have gone wrong and how it can be improved.

  • Please help me by solving the following query

    hi download the image from the above link and here i want latest dosi line count.....
    Please help me

    I think you don't need a plsql for this purpose ... you can find the sub total & final total in the query itself like
    select
         DOSI,
         ELEMENT_TYPE,
         SUM(USED)  USED
    from
         DOEMS_LICENSE_SUMMARY
    where
         DOSI in (DOSILIST)
    GROUP BY
         rollup(ELEMENT_TYPE, DOSI)      ** duplicate**

  • Please Solve The SQL Query

    Please Slove the Query as below:
              T1
    |     A1     |     A2     |
    |     TRUE     |     FALSE     |
    |     FALSE     |     TRUE     |
    |     TRUE     |     TRUE     |
    |     FALSE     |     TRUE     |
    Table Name is: T1 and it is having 2 columns A1 and A2.
    Question is:
    Using a simple SQL query try to get the total number of "TRUE" in the Table T1. Don't use any PL/SQL command,
    just use simple SQL command.
    Please write the full query.
    Manojit.

    select (Nvl(a.cnt_a1,0) + Nvl(b.cnt_a2,0)
    from (select count(1) CNT_A1 from t1 where a1 = 'TRUE') A
    (select count(1) CNT_A2 from t1 where as = 'TRUE') B
    Please Slove the Query as below:
              T1
    |     A1     |     A2     |
    |     TRUE     |     FALSE     |
    |     FALSE     |     TRUE     |
    |     TRUE     |     TRUE     |
    |     FALSE     |     TRUE     |
    Table Name is: T1 and it is having 2 columns A1 and A2.
    Question is:
    Using a simple SQL query try to get the total number of "TRUE" in the Table T1. Don't use any PL/SQL command,
    just use simple SQL command.
    Please write the full query.
    Manojit.

  • Missing Some Select input options the Query

    Hello all,
    Normally when i excute a query, it will ask for date range and year, fiscal period etc input options which i have to input to execute a given query. But  for one of the BWuser(sales guy) iam unable to see the fields, can anyone guess what cud be the problem. do you think its something to do with the BW authorization? any ideas to solve the problem are appreciated.
    Thanks
    SP

    Hi, you need to force the variables to be asked.
    Add &variable_screen=X at the end of the URL of the report. Check if then the values are requested.
    Hope this helps.
    Regards,
    Diego

  • Problem with exceptions in the query designer

    Hi all,
    i got this problem, there is a formula, than calculate  "A"   %A   "B", This bring a value %, ok.
    in my exceptions i got this ranges:
    1  to  99,4  Bad 9
    99,5 to 100  Good 1,
    i execute the query and this bring the results, when there is a line with value 99,5, this appear without color, the rest is ok,
    why this happend? whats the solution? please guys, i'll award you

    i m sorry the values are
    0 to 99,4 Bad 9
    99,5 to 100 Good 1
    i solve it by this way
    0  to 99,49999999999  Bad 9
    99,5000000001 to 100 Good 1
    i looks like the internal value of the KF is with a lot of decimal, the problem here is, when the value is 99,5 exactly, dont appear color, but i dont know how else solve it, any advice?

  • In the report builder 6i when I choose the query  type as Express Query .....

    In the report builder 6i when I choose the query type as Express Query and go to next step where on pressing the connect button I am getting the following error.
    REP-6029 : Express error.
    How can I solve this problem ?
    Thanks
    Nanda Kishore

    DiId you download Oracle Reports Developer/Server Release 6i for Express, Files for Oracle8i for Windows NT from OTN?
    If so, could you provide me wih more information?
    Thanks
    Elaine

  • "The query was cancelled" error after upgrade from 10.1.3.3.3 to 10.1.3.4.2

    Hi,
    I was using OBIEE 10.1.3.3.3 /. After upgrading to 10.1.3.4.2 , the queries are not running ( long running queries alone) as expected. and so all the campaigns iwh tlong running queries are cancelled and the error message is seen in the xml log in Marketing jobs management.
    We have upgraded the OBIEE version from 10.1.3.3.3 to 10.1.3.4.2 yesterday after which the connectivites have been checked with SQLPLUS and they are working fine. But when the campaign has been loaded, the Analytics have received the request for the segment query and after longer run, the task has been cancelled with the error message "The Query was cancelled as mentioned below in the Job Stats
    <jobStats>
    <jobID>2</jobID>
    <jobType>WriteListFiles</jobType>
    <jobUser>userid</jobUser>
    <jobState>Error</jobState>
    <jobTotalMilliSec>1h 41m 21s 160ms</jobTotalMilliSec>
    <jobStartedTime>2012-03-22T08:06:13Z</jobStartedTime>
    <jobFinishedTime>2012-03-22T09:47:34Z</jobFinishedTime>
    <jobIsCancelling>N</jobIsCancelling>
    - <exception>
    <message>Job request of type "WriteListFiles" failed.</message>
    - <exception>
    <message>Error executing the list generation SQL.</message>
    - <exception>
    <message>Error in executing cursor for WorkNode (Id:0)</message>
    - <exception>
    <message>The query was cancelled.</message>
    </exception>
    </exception>
    </exception>
    </exception>
    </jobStats>
    Please let us know the suggestions
    So far, the unaccessedtimingrunoutminutes tag has been tried to set 50 under ODBC tag in instanceconfig.xml. and the defaulttimeoutminutes has been tried to set to 150 in the same instanceconfig.xml.
    along with that the rpd changes are done. For all the users apart from the Administrator, the timeout has been changedfrom 10 minutes to 150 minutes. But still that way is not working.
    The segments was fired with the Administrator login. So , if the timeout for admin login can be set, i assume that the problem might be solved. Please let us know ur suggestions here too.
    If that is the case, when we open rpd , only for Administrator user and group, the Permissions button is disabled. So i want to know how to change for Admin user settings in rpd..
    Please advice us on the same.
    Regards,
    Madasamy M.
    Edited by: Madasamy Murugaboobathi on Mar 26, 2012 1:40 PM

    The issue has been resolved by setting the following parameters
    <UnaccessedRunningTimeoutMinutes>120</UnaccessedRunningTimeoutMinutes>
    <DefaultTimeoutMinutes>120</DefaultTimeoutMinutes>
    <ClientSessionExpireMinutes>120</ClientSessionExpireMinutes>
    <ConnectionExpireMinutes>120</ConnectionExpireMinutes>
    <UIDefaultTimeoutMinutes>1440</UIDefaultTimeoutMinutes>

  • Count no. of records for a particular customer in the query?

    Hi,
    1)Can anybody guide as to how do we count the number of records for a particular customer. E.g.
    C1 has placed 2 orders
    C2 has placed 4 orders
    C3 has placed 5 orders
    so in all the ODS has 11 records. Now while designing the query we need to ensure that we show only the Customers who have placed more than 3 orders. What could be logic to solve this kind of a problem?
    2) Is there a way that we can access the structure and data of the ODS in ABAP code say one of the includes in a user exit?
    The requirement says there could be N number of cases opened and closed in one month. Now we need to calculate the average number of days taken to close a case? Any ideas on the possible solution.
    Thanks
    RB

    Hi Rajat,
      Take a calculated key figure rename it as Count , go to the properties of that calculated key figure on the left hand side not at the columns side in the properties click on the button Enhance which is shown in the down left side, in the exception aggregation part select "count all values <>0" , take the reference character as customer Id . Now go to the Customer character which is in rows go to properties and select  "Normalise to" combo box  in that select "Query result" now u will get the exact result which ur looking for .

  • Error at report designer while opening the query

    Hi
    in report designer i am trying to open query
    i am getting error like
    error while loading query meta data
    check the query and portal settings
    i am getting this error only this report only
    Diagnosis
    An error occurred in the BI components on the SAP J2EE Engine.
    System Response
    Procedure
    Contact your system administrator to have the error analyzed in detail.
    Procedure for System Administration
    Start the Visual Administrator, log on to the SAP J2EE Engine and choose "<J2EE_SID>" ->"Server" -> "Services" -> "Log Viewer".
    The file "defaultTrace.trc" includes detailed information about the error that occurred. In Windows, you can find this file in the Log Viewer under "Cluster <computer name>" -> "Server <server number>" -> "<drive>:\usr\sap\<SID>\JC<INSTANCE>\j2ee\cluster\server<NUMBER>\log". ". In Unix, the file is located under "/usr/sap/<SID>/JC<INSTANCE>/j2ee/cluster/server<NUMBER>/log".
    If the file does not include enough detail about the error, you can increase the log level to obtain more information. To do this, choose "<J2EE_SID>" -> "Server" -> "Services" -> "Log Configurator". On the "Locations" tab page, choose "com" -> "sap" -> "ip" -> "bi" -> "webapplications". Using the selection list on the right side of the screen, you can increase the log level, whereby "DEBUG" represents the log level with the most information. You can save your settings by choosing the "Save" icon. The change to the log level is active immediately. Once you have successfully analyzed the error, you should set the log level back to its default value using the appropriate pushbutton; continuous writing to the log file negatively affects the overall performance of the system.

    Hi Suneel,
    If you are using any JAVA based applications or objects in the Report designer this error is thrown.
    It's better to install Java engine to correct this error.
    You must contact Basis people in order to solve this issue.
    With Regards,
    Ravi Kanth

  • Serious system error while executing the query: java.lang.OutOfMemoryError

    From ALSB, we are trying to insert records in a table, by calling the ALDSP webservice. It is working fine when the xml (ie., given as input to the ALDSP webservice) is small. But facing the following error when the input xml size is large.
    <ALDSP> <BEA-000000> <Product> <Serious system error while executing the query:
    {ld:ABC/Test}createTest:1
    java.lang.OutOfMemoryError: Java heap space
    We do not want to increase the heap size. Is there any other way we can solve this problem?

    In logical dataservice of ALDSP we have created a procedure called createTest, which is used to insert mulitple rows in the table. We have created a webservice for that logical DataService.
    Using the ALSB, we are calling the webservice -> createTest Operation and we are passing xml as input to that createTest function.
    Input xml:
    <ns1:createTest>
    <ns1:createTemps>
    <ns0:createTemp>
         <ns0:field1>1</ns0:field1>
              <ns0:field10>test1</ns0:field10>
    </ns0:createTemp>                
    <ns0:createTemp>
         <ns0:field1>2</ns0:field1>
              <ns0:field10>test2</ns0:field10>
    </ns0:createTemp>
         </ns1:createTemps>     
    </ns1:createTest>
    each ns0:createTemp represent a row that need to be inserted in the table.
    When the number of ns0:createTemp is less ( when the number of rows that need to be inserted is less) then no problem occurs, it is getting inserted properly. But when there are more number of ns0:createTemp then we are getting the following error
    <ALDSP> <BEA-000000> <Product> <Serious system error while executing the query:
    {ld:ABC/Test}createTest:1
    java.lang.OutOfMemoryError: Java heap space

  • Dump while executing the Query

    Hi,
    when I try to execute the query I get the following dump.
    ASSIGN_TYPE_CONFLICT
    Error analysis
    You attempted to assign a field to a typed field symbol,
    but the field does not have the required type.
    Pleaes assist , its urgent
    Regards,
    ANita

    Hi,
    The problem is Solved.
    If the problem is occuring while running the query,  regenerate the query through transaction RSRT.
    Regards,
    ANita

Maybe you are looking for

  • Set up iphone 4s loop

    Well so far the switch from an iphone 3gs to a 4s has been complete ****.  I updated my itunes, updated my 3gs, then synced them.  Then I followed the step by step instructions on my new 4s and all the **** phone does in itunes is loop in the initial

  • Sql retrives record but fails when used in a view

    Hi, I have a unique problem. I am able to retrive a record based on a certain criteria using a SQL. When the same sql is used in a create view statement the records do not show up. I did a count on records using the sql and get 54,521 where a count o

  • Muse crashes everytime I go to publish and says no such Id in the Mapping ?

    When I go to publish a muse site it stops at 41% everytime and says there is no such Id in the mapping .. this is crazy .. please can someone tell me how to fix this..

  • Creating space for scratch volume

    Being in the process of setting up scratch file space for my FCP, I am wondering if I couldn't use my second iMac (10.5) which has a new HD with 1.5 TB and 1 TB empty space, to store at least part of my FCP folders, I am thinking of the original AVCH

  • SAP Note  1276846

    When I am applying the adjust to original functionality in the General Structure tab in the Group and Process Areas for project ZGP_NHHR. I am getting the bug No version for structure element.And when executing the T-code /nSA_PROJECT_UPGRADE the err