Oracle query for top two salary of each group departmentwise

oracle query for top two salary departmentwise

sigh...
But anyway,
Top-n queries:
http://www.oracle.com/technology/oramag/oracle/07-jan/o17asktom.html
http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:2853107469873
and ofcourse lots of 'em here on OTN...

Similar Messages

  • How to find top utilized query for last two months in oem

    how to find top utilized query for last two months in oracle enterprise manager?

    Can you mark the thread as Helpful  and once marked the information can be reviewed by other customer for similar queries
    Regards
    Krishnan

  • SQL Query for TOP 10 Average CPU

    Have a SCOM Report request for a line graph showing top 10 average CPU for a group of servers. I have a query that will show all of the servers in a group for the last day, with the average CPU by hour. How can I extend the SQL query to only select the TOP
    10 average CPU from the group? Here is the Query I have:
    SELECT
    vPerf.DateTime,
    vPerf.SampleCount,
    cast(vPerf.AverageValue as numeric(10,2)) as AverageCPU,
    vPerformanceRuleInstance.InstanceName,
    vManagedEntity.Path,
    vPerformanceRule.ObjectName,
     vPerformanceRule.CounterName
    FROM Perf.vPerfHourly AS vPerf INNER JOIN
     vPerformanceRuleInstance ON vPerformanceRuleInstance.PerformanceRuleInstanceRowId = vPerf.PerformanceRuleInstanceRowId INNER JOIN
     vManagedEntity ON vPerf.ManagedEntityRowId = vManagedEntity.ManagedEntityRowId INNER JOIN
     vPerformanceRule ON vPerformanceRuleInstance.RuleRowId = vPerformanceRule.RuleRowId
    WHERE
    vPerf.DateTime  >= DATEADD(Day, -1, GetDate())
    AND vPerformanceRule.ObjectName like '%Processor Information%'
    AND vPerformanceRuleInstance.InstanceName = '_Total'
    AND (vPerformanceRule.CounterName IN ('% Processor Time'))
    AND (vManagedEntity.Path IN (SELECT dbo.vManagedEntity.Name
    FROM dbo.vManagedEntity INNER JOIN
    dbo.vRelationship On dbo.vManagedEntity.ManagedEntityRowId = dbo.vRelationship.TargetManagedEntityRowId INNER JOIN
    dbo.vManagedEntity As CompGroup On dbo.vRelationship.SourcemanagedEntityRowId = CompGroup.ManagedEntityRowId
    WHERE CompGroup.DisplayName = 'bemis ibb prod'
    ORDER BY path, vPerf.DateTime
    Results
    DateTime
    SampleCount
    AverageCPU
    InstanceName
    Path
    ObjectName
    CounterName
    2/26/15 3:00 PM
    2
    1.98
    _Total
    servername.corp.com
    Processor Information
    % Processor Time
    2/26/15 4:00 PM
    2
    2.09
    _Total
    servername.corp.com
    Processor Information
    % Processor Time
    2/26/15 5:00 PM
    2
    1.72
    _Total
    servername.corp.com
    Processor Information
    % Processor Time
    2/26/15 6:00 PM
    2
    1.83
    _Total
    servername.corp.com
    Processor Information
    % Processor Time
    Thanks in Advance!
    Mike Hanlon

    Hi 
    Sql Query
    SELECT TOP 10
    vPerf.DateTime,
    vPerf.SampleCount, 
    cast(vPerf.AverageValue as numeric(10,2)) as AverageCPU,
    vPerformanceRuleInstance.InstanceName, 
    vManagedEntity.Path, 
    vPerformanceRule.ObjectName, 
     vPerformanceRule.CounterName
    FROM Perf.vPerfHourly AS vPerf INNER JOIN
     vPerformanceRuleInstance ON vPerformanceRuleInstance.PerformanceRuleInstanceRowId = vPerf.PerformanceRuleInstanceRowId
    INNER JOIN
     vManagedEntity ON vPerf.ManagedEntityRowId = vManagedEntity.ManagedEntityRowId INNER JOIN
     vPerformanceRule ON vPerformanceRuleInstance.RuleRowId = vPerformanceRule.RuleRowId 
    WHERE 
    vPerf.DateTime  >= DATEADD(Day, -1, GetDate())
    AND vPerformanceRule.ObjectName like '%Processor Information%'
    AND vPerformanceRuleInstance.InstanceName = '_Total'
    AND (vPerformanceRule.CounterName IN ('% Processor Time'))
    AND (vManagedEntity.Path IN (SELECT dbo.vManagedEntity.Name
    FROM dbo.vManagedEntity INNER JOIN
    dbo.vRelationship On dbo.vManagedEntity.ManagedEntityRowId = dbo.vRelationship.TargetManagedEntityRowId INNER
    JOIN
    dbo.vManagedEntity As CompGroup On dbo.vRelationship.SourcemanagedEntityRowId = CompGroup.ManagedEntityRowId
    WHERE CompGroup.DisplayName = 'bemis ibb prod'
    ORDER BY path, vPerf.DateTime
    Regards
    sridhar v

  • Standard Query for Top 10 queries and Users

    Hi Experts,
    Is there any query which gives the details like ,
    1. Top 10 queries executed in a month
    2. Top 10 users ( By no of queries executed )
    Regards,
    Bhadri M.

    1. Top 10 queries executed in a month
    Use Query 0TCT_MCA1_Q0142.
    In this report you will have to filter variable BI Object to Queries and also it gives stats for the last 30 days, you have have to remove the SAP User exit variable in case you do not want to use the 30 days option. And then you will have to define Condition for Top 10.
    2. Top 10 users ( By no of queries executed )
    Use Query 0TCT_MCA1_Q0141.
    Similarly you have to modify this query.
    -Neelesh

  • Oracle Query for Oracle RAC

    Hi Everyone,
    I want oracle query with which we can retrieve information about oracle RAC.
    This information is, No of Clusters, Db instances...
    Which Tables i can query for this information?
    Thank You In Advance...
    Roshan

    Hi,
    I think you would mean active instances on your cluster....
    Query v$active_instances
    04/05/[email protected]=287> select * from v$active_instances;
    INST_NUMBER INST_NAME
    1 rac1:ORCL1
    2 rac2:ORCL2
    2 rows selected.
    Regards,
    Rodrigo Mufalani
    http://mufalani.blogspot.com

  • Oracle query for getting discrepancy equip codes

    I need help in getting a query for discrepancy equip_code
    select distinct eq.dept_id,eq.drive_id,equip_code,eq.qc_subtype_id,staff_id
    from qc_equipment_used eq, qc_daily qc
    where eq.drive_id = qc.drive_id
    and trunc(eq.create_time) = '06-aug-2012'
    and out_of_service = 'N'
    and eq.qc_subtype_id in (1026,1012)
    and eq.drive_id = 'DRV2016637'
    DEPT_ID|DRIVE_ID|EQUIP_CODE|QC_SUBTYPE_ID|STAFF_ID
    95|DRV2016637|HEMORYA121|1012|0011
    95|DRV2016637|HEMORYA121|1026|0011
    95|DRV2016637|HEMORYA148|1012|0011
    I need help in getting a query to show the user that
    95|DRV2016637|HEMORYA148|1012|0011
    was qc'd in the morning but not in the evening for 1026

    You still refuse to read {message:id=9360002} and follow the Forum Etiquette?
    How sad for you, since less volunteers will help you.

  • Query for top 10 selling products and their current stock

    Hi ppl
    I am using the sales overview cube 0SD_C03 to get top 10 selling products. What I want is to get the current stock available of the top 10 products from Material Stocks/Movements cube 0IC_C03. From what I know, we have to make a multiprovider to get this information. Can anyone guide me how to go about it?

    Hello Javed,
                         You can use Replacement path for this.
    1.Create a report for Top 10 Products in InfoCube 0SD_C03 - Exampls Report A
    2.Create another report with Stock and use a variable for Product with processing type replacement path in InfoCube0IC_C03 - Example Report B
    3. In Report B and assing the Report A to this variable.
    When you execute the Report B it will execute the Report A in background and displays it in Report B.
    Hope it helps,
    thanks
    Chandran

  • SQL Query to find missed nunmber from each group

    Hi,
    I have a set of records called "Level" and its values are A, B, C, D.
    From the below list, I want to identify the missed level for each group.
    ID          Level          Type
    1             A               Floor
    1             B                Floor
    2             A               Wind           
    2             C                Wind
    I need result like: [Missed level records]
    ID          Level          Type
    1               C             NULL     1- doesnt has C and D
    1               D             NULL
    2               B             NULL      2- doesnt has A and C
    2               D             NULL
    Pls suggest.
    Regards,
    -Sugumar Pannerselvam

    Hi,
    Got output with below code. may helpful for others.
    DECLARE @TblLevel TABLE(Level VARCHAR(10))
    INSERT INTO @TblLevel(Level) VALUES('A'),('B'),('C'),('D')
    DECLARE @TblRecords TABLE(ID INT, Level CHAR(1), Type VARCHAR(10))
    INSERT INTO @TblRecords(ID, Level, Type) VALUES(1,'A','Floor'),(1,'B','Floor'),(2,'A','Wind'),(2,'C','Wind')
    DECLARE @TblResult TABLE(ID INT, Level CHAR(1), Type VARCHAR(10))
    INSERT INTO @TblResult(ID, Level, Type)
    SELECT DISTINCT ID, TblLevel.Level, Type
    FROM @TblRecords TblRec
    CROSS JOIN @TblLevel TblLevel
    SELECT TblResult.* FROM @TblResult TblResult
    LEFT OUTER JOIN @TblRecords TblRec ON TblResult.ID = TblRec.ID AND TblResult.Level = TblRec.Level
    WHERE TblRec.Level IS NULL
    ORDER BY 1
    Looking for some best way to achieve this. As of now considered this as answer. :-)
    Regards,
    Sugumar Pannerselvam.

  • Query for Linking Two Tables without Reference

    Hi Folks,
    Good Day!
    I have this dilemma on how to link two tables without a reference. In the Business Partner Master Data, there is a field for the Territory which is from the table OTER. This OTER focuses on its description. Once you have added the particular Territory for that Business Partner, it is being stored in the Territory field of the BP right? Our client wants to have an automated way of searching for the Business Partner's Profit Center in creating a Sales Order wherein it is the same as the Business Partner's Territory. The Profit Center is from the table OPRC.
    When I create a Sales Order, after I have entered the Business Partner/Customer Code, the Profit Center should have the value of the Profit Center Code wherein it is the Business Partner's Territory. My query will go like this:
    Enter the BP/Customer Code automatically the Profit Center code where Profit Name = BP's Territory.
    OTER and OCRD don't have connections. How can it be?
    I'm thinking of retrieving the Territory first before the Profit Center but can you suggest of any other way?
    Thank you much!
    Regards,
    Fringe

    Hi Fringe,
    Okay, I already understood your case here. I presume your configuration as follows:
    OTER (Territory)
    territryID - descript
    1 - Philippine
    2 - Indonesia
    3 - Germany
    OPRC (Cost Centre)
    PrcCode - PrcName
    25 - Philippine
    33 - Indonesia
    47 - Germany
    Was above illustration correct? Then, you could use this formatted search in Cost Centre / Dimension field in Sales Order rows
    SELECT PrcCode FROM OPRC WHERE PrcName=(
    SELECT TOP 1 descript FROM OTER T0
    INNER JOIN OCRD T1 ON T0.territryID=T1.Territory
    WHERE T1.CardCode=$[OCRD.CardCode.0])
    However, I suggest you use a little bit different approach here. Since you can't define Territory Code / Territory ID (you could only type the Territory name, Philippine etc.), why don't you standardize Territory name with Cost Centre code? Let say, you define Philippine as PHI, Indonesia as INA, Germany as DEU and so on. Therefore, user can read the Cost Centre or more precisely Distribution Rules in Sales Order form in more familiar way.
    OTER (Territory)
    territryID - descript
    1 - PHI
    2 - INA
    3 - DEU
    OPRC (Cost Centre)
    PrcCode - PrcName
    PHI - Philippine
    INA - Indonesia
    DEU - Germany
    When FMS worked in Sales Order document, your user will read PHI instead of 25, should be more familiar to them. With that being said, you could use simpler FMS
    SELECT descript FROM OTER T0
    INNER JOIN OCRD T1 ON T0.territryID=T1.Territory
    WHERE T1.CardCode=$[OCRD.CardCode.0]
    You only need to maintain consistency between Territory Name and Cost Centre code. Just my two cents. Hope this help.
    Best Regards,
    Hendry Wijaya

  • Query for top 5 items

    Hi All,
    Looking for a query that would return the top 5 sales items along with sales values, between a date range
    Thanks
    Ranjit Krishnan

    Hi,
    You may try this if Credit Memos do not need to be included:
    SELECT TOP 5 T1.ItemCode, MAX(T1.Dscription) as 'Item Description',  SUM(T1.LineTotal) as 'Amount(LC)'
    FROM dbo.OINV T0
    INNER JOIN dbo.INV1 T1 ON T1.DocENtry = T0.DocENtry
    WHERE t0.docdate >= [%0\] and t0.docdate <= [%1\] AND t0.doctype = 'I'
    GROUP BY T1.ItemCode
    Order by SUM(T1.LineTotal) DESC
    Thanks,
    Gordon

  • MDX Query for Top 10 in SSAS Project

    Hi Guys,
    Please I need an MDX query that will help me calculate Top 10 inside the SSAS project.
    Your help will be greatly appreciated.
    Thanks
    me

    Hi,
    I know nothing about PowerView and PerformancePoint Server but I played with Excel and I am able to use the named set I created. Here are the steps which I followed.
    1 - Create the named set. Remember... this name set appears inside the dimension which you use as the first parameter inside TOPCOUNT function.  
    2 - Deploy the cube and perform a process full.
    3 - Navigate to PowerPivot ribbon and click on PowerPivot Window.
    4 - Choose From Database > From Analysis Services or PowerPivot. Specify the necessary SSAS server credentials and connect to the Cube which you are interested.
    When it comes to the MDX query design window you construct your MDX code in SSMS and copy that code. You also can use the design mode as well. In this case you have to toggle the "design mode" option and enter to manual mode which you can type
    your MDX code. Here is a screenshot of that.
    5 - Validate your query and click Finish. Once the data is in you can create your power pivot report. Here is an example.
    I hope this helps to troubleshoot your issue.
    Best regards...
    Chandima Lakmal Fonseka

  • Query for between two dates.

    Hi,
    I've a column of date, and I want to select the records between two dates, the output of this columns is: 08/19/2003 2:11:00 AM
    My query is:
    SELECT DTM FROM ITEM
    WHERE DTM BETWEEN '07/01/2012' AND '07/15/2012'
    Please help.
    Thanks,

    >
    I've a column of date, and I want to select the records between two dates, the output of this columns is: 08/19/2003 2:11:00 AM
    My query is:
    SELECT DTM FROM ITEM
    WHERE DTM BETWEEN '07/01/2012' AND '07/15/2012'
    Please help.
    >
    Help with what? You didn't ask a question or indicate if you are having a problem of some sort.
    Did you need to know how to use TO_DATE instead of literals in the WHERE clause?
    SELECT DTM FROM ITEM
    WHERE DTM BETWEEN TO_DATE('07/01/2012', 'MM/DD/YYYY') AND TO_DATE('07/15/2012', 'MM/DD/YYYY');

  • Query for comparing two columns in two tables

    Hai, all,
    I have following two tables and columns, I need to get the rows (all columns) from scott.cp_ip which are not ( the same value present in t1 and also in t2).
    Table scott.cp_ip column cp_ip.vrno = Table scott.cb1 column cb1.cb_vnno
    I used the following query and did not get the correct result:
    select * from scott.cp_ip where cp_ip.vrno in (select cb1.cb_vnno from scott.cb1);
    Can you please tell how it can be solved?
    Thanks in advance.
    Rcs
    SQL> desc scott.cb1;
    Name Null? Type
    ID NUMBER
    SUPCODE NUMBER
    SUPLNAME VARCHAR2(100)
    NAME VARCHAR2(100)
    ITEMCODE VARCHAR2(10)
    RECDOC NUMBER
    RECDATE VARCHAR2(10)
    TOTVALUE NUMBER
    QTY NUMBER
    CB_IPNO NUMBER
    CB_VNNO NUMBER
    CB_VDT VARCHAR2(10)
    CB_AMT NUMBER
    SQL> desc scott.cp_ip;
    Name Null? Type
    ID NUMBER
    VRNO NUMBER
    CODE VARCHAR2(50)
    HEAD VARCHAR2(255)
    PARTI VARCHAR2(255)
    CR NUMBER
    SQL> select * from scott.cp_ip
    2 intersect
    3 select * from scott.cb1;
    select * from scott.cp_ip
    ERROR at line 1:
    ORA-01789: query block has incorrect number of result columns
    SQL> (select * from scott.cp_ip
    2 minus
    3 select * from scott.cb1)
    4 union all
    5 (select * from scott.cb1
    6 minus
    7 select * from scott.cp_ip);
    (select * from scott.cb1
    ERROR at line 5:
    ORA-01789: query block has incorrect number of result columns
    SQL> select * from scott.cp_ip where cp_ip.vrno in (select cb1.cb_vnno from scott.cb1);
    result=instead of 1408 rows, 1481 rows (excess 73 rows) getting!
    ----------

    Instead of SELECT * write only the column that you want to compare. I guess that would be cb1.cb_vnno and cp_ip.vrno.

  • Query For Retrieving Data With Date and grouping

    Hi Guys
    I am having a hard time to figure out the sql query.
    I have a table with data. Below is the illustration.
    date location  item description
    1 jan 14 A  apple desc1
    2 jan 14 A  apple desc2
    3 jan 14 B  apple desc1
    4 jan 14 B  apple desc2
    1 jan 14 A  orange desc1
    2 jan 14 A  orange desc2
    3 jan 14 B  orange desc1
    4 jan 14 B  orange desc2
    My question it how to get the latest date on each location and item along with the description field
    This is the result I want
    date location  item description
    2 jan 14 A  apple desc2
    4 jan 14 B  apple desc2
    2 jan 14 A  orange desc2
    4 jan 14 B  orange desc2
    Thanks.

    provided it a datetime/date field you've for date you can do this
    SELECT [date],location,itemdescription
    FROM
    SELECT [date],location,itemdescription,
    ROW_NUMBER() OVER (PARTITION BY location ORDER BY [date] DESC) AS Rn
    FROM table
    )t
    WHERE Rn = 1
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • Urgent: Oracle Reports : Blank Page Should print after each Group of record

    Hi all,
    I have a different kind of requirement, in my report I have 1 block and I want to generate a blank page after every group of records. This is because the printer is printing both side of the paper and we are giving multiple group at same time.
    Cannot touch the printer setup since it is a common one. Anybody can help me in this for a fast and simple way ? "Maximum records per page" property for the repeating frame give the next group to a fresh page but there will not be a blank page in between.
    Please help ..
    Thanks,
    Ani.

    Thank you for your attention.
    Empty frame with page break is not helping me since it will not hide the rest of the items which are outside the repeating frame. Like Report caption, Group Name, Page footer etc...
    If I am using the empty frame, is there any way to hide all other items ?
    Thanks,
    Anish

Maybe you are looking for

  • SOA Suite Business Rules: Error caching the Decision Services metadata

    hi ofm users im currentntly trying SOA Suite 11.1.1.1.0 on Oracle XE on Windows XP Pro what im trying is a simple use case of business rule component, my service is getWorkStatusByDay, that i implement using business rules component using decision ta

  • H67ma-e35 won't overclock

    I have a h67ma-e35 mainboard with a I5-2500K CPU and I wan't to overclock, but it seems to be impossible to do so on this mainboard. Whenever I put the cpu on a higher mulitplyer and reboot it always reverts back to the old multiplyer and thereby und

  • HT1498 do you have to have your computer active, in order for apple tv to work?

    Do you have to have your computer active, in order for apple tv to work?

  • DMEE - Output in the required format

    Hi I need an output in this format: ........1........2........3........4........5........6.... 101 DEUT0797B CoCd    0905271433A094101DEUTSCHE BANK          Company Name         <CR/LF> 5200Company Name Payment Type      1         CCD     090527   1D

  • Consignment PIR not selected on PR during MRP

    Hello, I'm facing a problem where the consignment PIR is not selected in PR during PR creation through MRP run. Sourcing happens correctly and the supplier number in Source List is assigned to fixed vendor. However the info-record field is blank. Sur