How to get top 10 records for each option in table prompt?

Hi,
I have created one report in which my requirement is to get top 10 highest salaries for each departments. I have created one table prompt which contains the names of all departments. On the salary column I have applied one filter i.e. TOP 10. Currently I am having 3 departments. I want to show the top 10 salaries for each department, but I am getting top 3 from first, 4 from second and 3 from third.They are calculating top 10 salaries based on all departments, not on individual department. How can I get top 10 salaries for each department?

Hi,
Use TopN function in your column formula.
Ex: TOPN("Sales ,5 BY department)
Thanks,
Satya

Similar Messages

  • How to Get Missing Dates for Each Support Ticket In My Query?

    Hello -
    I'm really baffled as to how to get missing dates for each support ticket in my query.  I did a search for this and found several CTE's however they only provide ways to find missing dates in a date table rather than missing dates for another column
    in a table.  Let me explain a bit further here -
    I have a query which has a list of support tickets for the month of January.  Each support ticket is supposed to be updated daily by a support rep, however that isn't happening so the business wants to know for each ticket which dates have NOT been
    updated.  So, for example, I might have support ticket 44BS which was updated on 2014-01-01, 2014-01-05, 2014-01-07.  Each time the ticket is updated a new row is inserted into the table.  I need a query which will return the missing dates per
    each support ticket.
    I should also add that I DO NOT have any sort of admin nor write permissions to the database...none at all.  My team has tried and they won't give 'em.   So proposing a function or storable solution will not work.  I'm stuck with doing everything
    in a query.
    I'll try and provide some sample data as an example -
    CREATE TABLE #Tickets
    TicketNo VARCHAR(4)
    ,DateUpdated DATE
    INSERT INTO #Tickets VALUES ('44BS', '2014-01-01')
    INSERT INTO #Tickets VALUES ('44BS', '2014-01-05')
    INSERT INTO #Tickets VALUES ('44BS', '2014-01-07')
    INSERT INTO #Tickets VALUES ('32VT', '2014-01-03')
    INSERT INTO #Tickets VALUES ('32VT', '2014-01-09')
    INSERT INTO #Tickets VALUES ('32VT', '2014-01-11')
    So for ticket 44BS, I need to return the missing dates between January 1st and January 5th, again between January 5th and January 7th.  A set-based solution would be best.
    I'm sure this is easier than i'm making it.  However, after playing around for a couple of hours my head hurts and I need sleep.  If anyone can help, you'd be a job-saver :)
    Thanks!!

    CREATE TABLE #Tickets (
    TicketNo VARCHAR(4)
    ,DateUpdated DATETIME
    GO
    INSERT INTO #Tickets
    VALUES (
    '44BS'
    ,'2014-01-01'
    INSERT INTO #Tickets
    VALUES (
    '44BS'
    ,'2014-01-05'
    INSERT INTO #Tickets
    VALUES (
    '44BS'
    ,'2014-01-07'
    INSERT INTO #Tickets
    VALUES (
    '32VT'
    ,'2014-01-03'
    INSERT INTO #Tickets
    VALUES (
    '32VT'
    ,'2014-01-09'
    INSERT INTO #Tickets
    VALUES (
    '32VT'
    ,'2014-01-11'
    GO
    GO
    SELECT *
    FROM #Tickets
    GO
    GO
    CREATE TABLE #tempDist (
    NRow INT
    ,TicketNo VARCHAR(4)
    ,MinDate DATETIME
    ,MaxDate DATETIME
    GO
    CREATE TABLE #tempUnUserdDate (
    TicketNo VARCHAR(4)
    ,MissDate DATETIME
    GO
    INSERT INTO #tempDist
    SELECT Row_Number() OVER (
    ORDER BY TicketNo
    ) AS NROw
    ,TicketNo
    ,Min(DateUpdated) AS MinDate
    ,MAx(DateUpdated) AS MaxDate
    FROM #Tickets
    GROUP BY TicketNo
    SELECT *
    FROM #tempDist
    GO
    -- Get the number of rows in the looping table
    DECLARE @RowCount INT
    SET @RowCount = (
    SELECT COUNT(TicketNo)
    FROM #tempDist
    -- Declare an iterator
    DECLARE @I INT
    -- Initialize the iterator
    SET @I = 1
    -- Loop through the rows of a table @myTable
    WHILE (@I <= @RowCount)
    BEGIN
    --  Declare variables to hold the data which we get after looping each record
    DECLARE @MyDate DATETIME
    DECLARE @TicketNo VARCHAR(50)
    ,@MinDate DATETIME
    ,@MaxDate DATETIME
    -- Get the data from table and set to variables
    SELECT @TicketNo = TicketNo
    ,@MinDate = MinDate
    ,@MaxDate = MaxDate
    FROM #tempDist
    WHERE NRow = @I
    SET @MyDate = @MinDate
    WHILE @MaxDate > @MyDate
    BEGIN
    IF NOT EXISTS (
    SELECT *
    FROM #Tickets
    WHERE TicketNo = @TicketNo
    AND DateUpdated = @MyDate
    BEGIN
    INSERT INTO #tempUnUserdDate
    VALUES (
    @TicketNo
    ,@MyDate
    END
    SET @MyDate = dateadd(d, 1, @MyDate)
    END
    SET @I = @I + 1
    END
    GO
    SELECT *
    FROM #tempUnUserdDate
    GO
    GO
    DROP TABLE #tickets
    GO
    DROP TABLE #tempDist
    GO
    DROP TABLE #tempUnUserdDate
    Thanks, 
    Shridhar J Joshi 
    <If the post was helpful mark as 'Helpful' and if the post answered your query, mark as 'Answered'>

  • Qry:How to get different price for each price list (variable area) in order

    1-How to get different price for each price list (variable area) in order for sale. for the opportunity to display and select multiple prices.
    2- I add a location store from a table in line item and I want to see this area in order,.
    I 'm created 2 field location(item line and order), 1 table location
    I tried this for exemple : select $ [userfieldlocation.OITW]

    Thanks Suda for your answer,
    the Formatted Search for prices is OK, but for the Item locations in warehouse this is not so simple,     
    I must have several (at least 2) locations for the item in the Warehouse and a track of this location and search possibilities.
    read carefully and imagine how (Management warehouse locations)
    I added a user table '@Location' who linked to a user field 'U_Location in Item master data --> lnventory data  line and an ather user field 'U_Location' in sales order
    I met the value of location in the table (list of locations for any warehouse), I select the location of each item while receiving merchandise in the user field of inventory data line (Item M data) and this value appears in the sales order 'U_Location' user field ( only the location value in the default warehouse for this Item)
    or
    create an user field 'location' in Good receipt PO to fill it while receiving merchandise that appears in the sales order to give possibility to find/select the location of the item at this order and in Item master data
    I think we will use all these tables
    @LOCATION
    PDN1
    OITM
    OITW
    OWHS
    RDR1
    Juste a another question : where you found this and What is: ' 38.1.0 '
    Is it in document (System information):Item=38 Pane=1 ??
    Thanks,
    Ouchen

  • Loading the cube from 3 datasources and getting 3 records for each keyfield

    Hi All,
    I am loading an InfoCube from 3 separated datasources. These 3 datasources are UD Datasources and their unique source system is UD Connect.
    Each of the datasource contains a unique key field 'Incident Number' (same as we use have in Datasources for DSO).
    The problem is, when I am loading data with these 3 datasources to the cube, for each 'Incident number' there becomes 3 records.
    We have reports on this Infocube and the report also displays 3 records for each incident number.
    If I remove Incident Number key field from 2 of the Datasources, the data from these datasources do not reach to the Cube.
    For many of you, this may be a minor problem ( or may not be a problem at all !!! ) , but as a New Joinee in SAP field, this has become a showstopper issue for me.
    Please suggest.
    Thanks in Advance.

    Hi Pravender,
    Thanks for your interest.
    The scenario is, I have 3 datasources form the same source system, All the 3 datasources have different fields except 'Incident Number'. So, each and every field has only one value in the report. But due to 3 separate datasources, it creates 3 records displahying values of each datasource in a separate record.
    There is no field in the query output which is having different values for the different source systems. Due to 3 records in the cube, one record will contain the value for a particular field and the other two records will show a Blank for that field.
    Regards.

  • How to get the texts for each line item for Sales order in a smartform

    I'm createing a smart form in which i need to display certain texts for each line item of a sales order. How can i get those??
    I'm trying with the table STXH and FM read_text... but i'm not clear how and what i'm getting... can anybody pls help me.....

    Hi There,
    But then i will be getting only the value. i want to link that against the particular material of the Purchase Order.
    Like for ex:
    PO No.  Material Code        Line Item        Basic        Excise       Tax       Inv Value
    0000001 5000251                010               100           16         4.64      120.64
    0000001 5000252                020               200           32         9.28      241.28
    Can u help me on this?
    Regards,
    Jitesh

  • How to get committed date for each component after availability check

    Hi,
    When I use CO02 to check material availability, I can see committed date in missing part list and missing part overview for each component in production order. I save it and use CO03 to read missing part list again. The committed date is blank?! How to get the committed date for each missing part in production order?
    Another question, committed date can be displayed in CO24(missing parts info system)? Thanks in advance!!

    Rita,
    Please check that the PP avail. check has replensh lead time turned on. If RLT is turned off & there is no sufficient stock of material, then system can only committ date of 12/31/9999.
    Once you turn on RLT, it will give you some date based on your configured avail check ( that looks at stock or purchase order or production order). That way if there is no sufficient stock of material to satisfy your order system will committ the worst case date which is the RLT.
    On CO24 unfortunately there is no field for Committ date. Hence is it not possible to view commit date. You can only view Committ quantity.
    i am sure this will help you. Else please come back.
    thanks,
    Ram

  • How to get first emp for each dept?

    Hi,
    I need to do a query to pick up one employee (the first one based on ename or empno)from each department, but I don't want to use min function (for some reason it didn't work on my real date), rather I like to use something like this: The problem is I can only pick one instead of one for each dept.
    select ee.* from
    (select * from emp
    order by ename
    ) ee,
    emp e
    where rownum <2
    and e.deptno=ee.deptno
    Thanks

    How about this (if I understood your question correctly)?
    select * from
    (select distinct deptno from emp) depts,
    (select deptno, min(ename) from emp group by deptno) ees
    where ees.deptno = depts.deptno;
    Test:
    14:10:26 ==> create table emp (deptno number, ename varchar2(50));
    Table created.
    14:10:27 ==> insert into emp values (10, 'Joe');
    1 row created.
    14:10:27 ==> insert into emp values (10, 'Mary');
    1 row created.
    14:10:27 ==> insert into emp values (10, 'Ethel');
    1 row created.
    14:10:27 ==> insert into emp values (20, 'Luke');
    1 row created.
    14:10:27 ==> insert into emp values (10, 'Sue');
    1 row created.
    14:10:27 ==> insert into emp values (20, 'Bob');
    1 row created.
    14:10:27 ==> insert into emp values (30, 'Randy');
    1 row created.
    14:10:28 ==> select * from
    14:10:35 2 (select distinct deptno from emp) depts,
    14:10:35 3 (select deptno, min(ename) from emp group by deptno) ees
    14:10:35 4 where ees.deptno = depts.deptno;
    DEPTNO DEPTNO MIN(ENAME)
    10 10 Ethel
    20 20 Bob
    30 30 Randy

  • How to get the result from graph  based on table prompt?

    I have one report in which I am having one table and three Graphs. I have added table prompt for one column i.e department. In that I have given three values. The values of my table changes as per the table prompt. But my requirement is my graphs should show me the result as per the selection of departments in table prompt. Please give me the solution for the same.

    Hi,
    Create a event channel the table view and refer the same channel name in the graph properties.
    Edit Graph --> Edit properties --> Enable Master-Details Events --> Give the channel name.
    It will work for the selection of table .
    Mark if helps.
    Raja Mohamed

  • This is really a SQL question. How to get a record for the max value

    I have a table ZTX with the following fields and values
    VBELN  POSNR SEQNR DESCRIPTION
    3001             10   001  Desc1
    3001             10   002  Desc2
    3001             10   003  Desc3
    I want to create a query so that I can join tables VBAK-VBELN, and VBAP and ZTX. So that I only get the row of ZTX which has max (SEQNR) i.e 003 in this case. How can I write the SQL statement. Is there a way to write a single SQL statement which can retrieve from all three table VBAK, VBAP and ZTX maybe with a subquery or do I really have to first take the results of VBAK and VBAP join into internal table then fire query on ZTX.
    Thanks for reading

    Something like this
    Select * into table my_table from ztx as z
    join vbak as b on b~vbeln = z~vbeln
    join vbap as p on p~vbeln = z~vbeln " maybe posnr also?
    where
    z~seqnr = ( select max( seqnr ) from ztx where vbeln = z~vbeln ).

  • How to get row count(*) for each table that matches a pattern

    I have the following query that returns all tables that match a pattern (tablename_ and then 4 digits). I also want to return the row counts for these tables.
    Currently a single column is returned: tablename. I want to add the column RowCount.
    DECLARE @SQLCommand nvarchar(4000)
    DECLARE @TableName varchar(128)
    SET @TableName = 'ods_TTstat_master' --<<<<<< change this to a table name
    SET @SQLCommand = 'SELECT [name] as zhistTables FROM dbo.sysobjects WHERE name like ''%' + @TableName + '%'' and objectproperty(id,N''IsUserTable'')=1 ORDER BY name DESC'
    EXEC sp_executesql @SQLCommand

    The like operator requires a string operand.
    http://msdn.microsoft.com/en-us/library/ms179859.aspx
    Example:
    DECLARE @Like varchar(50) = '%frame%';
    SELECT * FROM Production.Product WHERE Name like @Like;
    -- (79 row(s) affected)
    For variable use, apply dynamic SQL:
    http://www.sqlusa.com/bestpractices/datetimeconversion/
    Rows count all tables:
    http://www.sqlusa.com/bestpractices2005/alltablesrowcount/
    Kalman Toth Database & OLAP Architect
    SQL Server 2014 Design & Programming
    New Book / Kindle: Exam 70-461 Bootcamp: Querying Microsoft SQL Server 2012

  • HOW TO GET "N" RECORDS, URGENT

    Hi,
    Can any one please tell me what will be the SQL statement to get 10 records for each department . I dont want top 10 , i just want to get 10 records for each department from the employee table. or lets say 10 orders for each day for last 30 days from the order table. This is very URGENT. Please help.
    Thanks in Advance

    Hi,
    Thanks for your reply . But you didnt get my question I guess. I said I dont want the top "N" records. I want a query to pull N records for each department . Here is a sample, which shows 3 records for each department. Though there can be many records in the table for each department, the select staement pulls only three records for each department. I want that select statement.
    Thanks
    Feroz
    deptno------------empno----------ename
    10 -------------------100------------feroz
    10--------------------110------------anwar
    10--------------------120-------------liakat
    20-------------------200--------------zahir
    20------------------210---------------inzam
    20------------------220---------------shakil
    30------------------300---------------rameh
    30------------------310--------------rajesh
    30-------------------320-------------ritesh

  • How to get latest record on top of the result list

    Hi Gurus,
    How to get latest record on top of the result list when you open the record.
    saved data method in BT120H_CPL of OverView page and result list in ICCMP_INBOX.
    Regards,
    Ravi

    Hi
    Try sort descending by on fileld "changed at ".
    manipulate the sort depends on your requirement
    Regards
    Logu

  • How to get the date for the first monday of each month

    Dear Members,
    How to get the date for the first monday of each month.
    I have written the following code
    SELECT decode (to_char(trunc(sysdate+30 ,'MM'),'DAY'),'MONDAY ',trunc(sysdate+30 ,'MM'),NEXT_DAY(trunc(sysdate+30 ,'MM'), 'MON')) FROM DUAL
    But it look bith complex.
    Abhishek
    Edited by: 9999999 on Mar 8, 2013 4:30 AM

    Use IW format - it will make solution NLS independent. And all you need is truncate 7<sup>th</sup> day of each month using IW:
    select  sysdate current_date,
            trunc(trunc(sysdate,'mm') + 6,'iw') first_monday_the_month
      from  dual
    CURRENT_D FIRST_MON
    08-MAR-13 04-MAR-13
    SQL> Below is list of first monday of the month for this year:
    with t as(
              select  add_months(date '2013-1-1',level-1) dt
                from  dual
                connect by level <= 12
    select  dt first_of_the_month,
            trunc(dt + 6,'iw') first_monday_the_month
      from  t
    FIRST_OF_ FIRST_MON
    01-JAN-13 07-JAN-13
    01-FEB-13 04-FEB-13
    01-MAR-13 04-MAR-13
    01-APR-13 01-APR-13
    01-MAY-13 06-MAY-13
    01-JUN-13 03-JUN-13
    01-JUL-13 01-JUL-13
    01-AUG-13 05-AUG-13
    01-SEP-13 02-SEP-13
    01-OCT-13 07-OCT-13
    01-NOV-13 04-NOV-13
    FIRST_OF_ FIRST_MON
    01-DEC-13 02-DEC-13
    12 rows selected.
    SQL> SY.

  • How to get wage type for every time record

    Hi Pros,
          I am using DS 0CA_TS_IS_1, it includes report time type (0REPTT), but not have wage type. in CATSDB, I fied fields for attendance/absence type and wage type. but not every time record has wage type. can you please tell me how to get wage type for every time record? what is relation between reporting time type, attendance/absence type and wage typs?

    Hello,
    Can you talk to your HR/T&E functional consultant if they populate these values in CATSDB table using standard way or if there are custom fields that are in CATSDB OR any other table which can be used to meed the requirements
    Thanks
    Abhishek Shanbhigue

  • How can I get delta records for Generic Delta

    Hi BW Gurus,
    I am using Generic Extractor using View from CATSDB and CATSCO talbes. At the time of modifying and changing records I am unable to get those records in BW despite enabling delta in RSO2 screen. I am able to view those modified and added records in R/3 in tables. Plz help me how I get those records to BW.

    hi,
    After we loaded all the historical data uing full upadate . Implemenattion process is over , But we will have the Transaction data that will raise daily , So we have to store that New / changed data in Delta q , And extract them each day by Delta Update
    So we will create an Info packege with the update mode as Delta , And schedule them when to start extraction , So we create the process chain uisng RSPC by giving the Info packege name . And extract the Detla daily as per schedule .
    award pts if helpful..

Maybe you are looking for