Filter the rows based on another column

Hello

I have a table like this:

user_idteamsla_teamrownum
11one01
22one02
33b13
44b14
55c3

5

I want a list of the first order of 3 users of sla_team.

If 2 or more users have the same sla_team, must list both of them.

In this case, I want to return user_id: 11, 22, 33, 44

A way to do it is like this:

Select *.

table

where sla_team < = (select max (sla_team) in the table where rownum < = 3)

But my table is bigger and more complex query.

Any other sugestion?

Thank you and sorry for my bad English.

Hello

Whenever you have a problem, please post a small example data (CREATE TABLE and only relevant columns, INSERT statements) of all the tables involved, so that people who want to help you can recreate the problem and test their ideas.

Also post the exact results you want from this data, as well as an explanation of how you get these results from these data, with specific examples.

Always say what version of Oracle you are using (for example, 11.2.0.2.0).

See the FAQ forum: Re: 2. How can I ask a question on the forums?

This sounds like a job for a Query of Top - N, like this:

WITH got_r_num AS

(

SELECT table_x. *- or whatever the columns that you want to

, EVALUATE () DURING (ORDER BY sla_team) AS r_num

FROM table_x

-WHERE... - If you need any filtering, put it here

)

SELECT *- or the list of all columns except r_num

OF got_r_num

WHERE r_num<=>

ORDER BY r_num

;

Tags: Database

Similar Questions

  • How do column filter based on another column

    In my report, I have column a thru d. I would like to create a filter based on another column where column is column B. I can enter a value that the column cannot be equal to, but I would use a column instead of a value.

    Thank you.
    Jonathan

    Try this: icon on the filter columns->-> convert this advanced filter for SQL
    You can reference any other column

    BTW: Have you had a chance to look at my suggestion for your post
    Tables from a Table

  • Get the cumulative values in a single column based on another column in reports

    Hi all

    I have a requirement to get cumulative values based on another column.
    I 'Sales rep name' in the first column.
    Correspondent "Values of the invoice line" in the second column.
    Want to have cumulative of all the values for each sales invoice line.
    Then apply rank and display the top 10 sales reps based on invoice lines.
    Since there is no rank option in the PivotTable, I do this in the report table.

    Looking for the best entries...

    Thanks in advance...

    Try below
    2nd column: "name of Sales rep.
    column 2: SUM ("invoice line values ' BY 'Name of Sales rep'") and sort this field desc.
    3rd column: fx RANK (SUM ("invoice line values" BY "Sales rep name")), to hide this column, so that you don't confuse your users.

    and put the filter on the 3rd column below 5

    I hope this works for you

  • Delete based on another column dublicate records

    How can I remove duplicate records, based on another column.

    the table structure
    CREATE TABLE IA_EXPORT_LEVEL
    (
    A_NO VARCHAR2 (22 BYTE),
    IM VARCHAR2 (18 BYTE),
    ctn_level NUMBER (2)
    )

    reviews
    A_NO IM ctn_level

    S1 S1 1
    S1 M1 2
    S1 h1 3
    H2 S2 1
    S2 h2 2
    S3 h1 2
    S3 h1 3
    S4 h6 4
    S4 h6 5

    I want to delete all records other than the minimum value of the ctn_level

    output should like below
    S1 S1 1
    H2 S2 1
    S3 h1 2
    S4 h6 4

    Published by: OraFighter on December 16, 2011 13:44
    DELETE FROM IA_EXPORT_LEVEL where rowid IN
    (select rid from
    (select rowid rid, row_number() over (partition by A_NO,IM order by ctn_level) rn from IA_EXPORT_LEVEL )
    where rn > 1 )
    /
    

    Hope your question.

  • I have a column with two values, separated by a space, in each line. How to create 2 new columns with the first value in a column, and the second value in another column?

    I have a column with two values, separated by a space, in each line. How do I create 2 new columns with the first value in one column and the second value in another column?

    Add two new columns after than the original with space separated values column.

    Select cell B1 and type (or copy and paste it here) the formula:

    = IF (Len (a1) > 0, LEFT (A1, FIND ("", A1) −1), ' ')

    shortcut for this is:

    B1 = if (Len (a1) > 0, LEFT (A1, FIND ("", A1) −1), ' ')

    C1 = if (Len (a1) > 0, Member SUBSTITUTE (A1, B1 & "", ""), "")

    or

    the formula of the C1 could also be:

    = IF (Len (a1) > 0, RIGHT (A1, LEN (A1) −FIND ("", A1)), "")

    Select cells B1 and C1, copy

    Select cells B1 at the end of the C column, paste

  • Filter column based on another column - OBIEE 11 g

    Hi, I have a strange requirement. I am trying to build a dashboard that allows a user to view the data for the current day, last week, last month or last year. I'll create a presentation called "date_range" variable where the user can choose one of these 4 options.

    On this basis, I defined a column in answers with the following formula:

    Cast
    (
    case
    When 1 = 0 then 'time of the query. "" Date ".
    When @{date_range} {"day"} = 'Day' then Current_Date
    When @{date_range} {'week'} = 'Week' then TIMESTAMPADD (SQL_TSI_DAY,-7, CURRENT_DATE)
    When @{date_range} {"day"} = 'Month' then TIMESTAMPADD (SQL_TSI_DAY-30, CURRENT_DATE)
    When @{date_range} {"day"} = 'Year' then TIMESTAMPADD (SQL_TSI_DAY,-365, CURRENT_DATE)
    of another TIMESTAMPADD (SQL_TSI_DAY,-10000, CURRENT_DATE)
    finish DATE
    )

    Based on the variable 4 presentation, this should give the good 'start date' when to extract data.

    Now, I've added the effective date of the date dimension column. But I need to put a filter on the date dimension date column that says that it is greater than or equal to the above computed column. How do I do that?

    Thank you
    Scott

    I always expect that you are pregnant, but you cannot filter a column on another column. The solution is just to write a formula that returns a literal, so it will be

    When case (your date column) > = (your long form), then put end to 'Y' else ' n

    Then filter this column on 'Y '.

    Kind regards

    Robert

  • AF:Switcher, handfuls of line column values based on another column in the table

    Hello

    I have a question if you can help me on this. It's on af:switcher.

    What I'm trying to do this - is in a table of the adf, based on the value of a column, I want another column to display as a link or not.
    For example, if the status column is 1, then the id column display as a link (I just put a h:outputLink around outputText to do), if it is then show him without bond.

    For this I put two different facets and opportunities switcher to decide what facet of show which line.

    BUT what is happening is that only on opportunities is made. Either / or scenario. It is not made each line according to the value of the status column.

    What is planned.

    I just tried with the dept table.

                    
                    
                    
                      
                    
                    
                    
                        
    
                      
                    
    

    The lines for which the deptno > 20, I wanted to display the pass as link and for the deptno<=20, log="" will="" be="" an="" input="" text.="" it="" works="" fine="" for="" me.="" probably,="" you="" may="" need="" to="" get="" rid="" of="" h:outputlink="" and="" use="" commandlink="" golink="">

    Arun-

  • Update of the table based on another

    Hello

    I'm trying to update a date column in a table based on another table. There is a unique ID in each table that identifies and connects each person:
    update patient_bu a set a.entry_date = (select b.entry_date from CLIENT_MED_DT b where a.id = b.id)
    This is the error:

    ORA-01427: einreihig subquery returns multiple rows


    The problem (I think) is that the select statement back several dates for records people. There are some people / records that have multiple entry dates, but I'm only interested in the most recent date.

    How can I update this table with only the most recent date?

    Thanks for any help,
    Matt

    Oh well, I forgot the UPDATE clause:

    SQL> create table patient_bu
      2  (id number
      3  ,entry_date date);
    
    Table created.
    
    SQL> create table client_met_dt
      2  (id number
      3  ,entry_date date);
    
    Table created.
    
    SQL> merge into patient_bu a
      2  using (select id
      3               ,max(entry_date) max_date
      4         from   client_met_dt
      5         group  by id
      6        ) b
      7  on    (a.id = b.id)
      8  when  matched then update
      9        set a.entry_date = b.max_date;
    
    0 rows merged.
    
  • Default value for the prompt based on another request

    Hello:

    I have a requirement where I need to define default values of messages based on another request.

    The guest is a quick Date.

    I have tried using the presentation variable and sql query writing, where is written "WHERE promo_id = @{variable}" "

    but it still does not.

    Please let me know a workaround for this problem.

    Thank you.

    -Vinay

    What determined your operator BETWEEN End Date? I guess it's variable. In addition, is the second report on the same page or another page of dashboard? Assuming that the two reports are on the same page, do the below. If this isn't the case, you can use the same guests on the second page of dashboard. Define the scope of "dashboard" and the selection of the user is wearing on the second page.

    The easiest way is to have 3 guests of dashboard: Promo_ID, Start_Dt and end_date. assign to these guests PVs: pvPromoID, pvStartDate and pvEndDate, respectively.

    Filter a report on pvPromoID and pvStartDate.

    The second report on the pvPromoID of the filter and use pvStartDate in the filter of the two report Date column. Assuming that the values BETWEEN are variable, so you can write the following on the column of your second report:

    "Table name". " Date ColumnName.<= '@{pvstartdate}'="" and="" table="" name"."date="" column="" name"=""><>

    And your Promo column, use the filter "Table name". "Class = ' @{pvPromoID}"

    When the user selects the Promo ID, Start Date and end Date in the guests, the first and second reports will be filtered accordingly.

  • Conditional formatting based on another column

    I created a conditional format in several columns, all based in a column: "Format Type". In a table view, the conditional formatting works very well for the metrics. For a text column, the conditional formatting only works if the column 'Type of formatting' appears on his left.
    Is this right? I don't remember having a similar problem with 10 OBIEE.
    Now I use OBIEE 11.1.5

    Thank you.

    Bug 12772993 is listed under the 11.1.1.6 fixed

    Hope this helps,
    Scott

  • How to divide the lines based on two columns...

    Hi all...
    I have a requirement.

    I have the product, sale, purchase price column... (total of three columns) in a data set.

    my data set is in such a way that... If the sale price is... There is no purchase price and vice versa...

    I need too present in a report, two tables:
    Table 1 includes only the elements of retail price
    Table 2 should only contain the right elements.
    Please see the below photo for good understanding...
    Is this feasible? Where do we need to impose a condition? I tried to impose a condition, but it doesn't seem to work

    http://i51.Tinypic.com/29xfdc6.jpg


    Help, please.

    Can you send me the xml file and the model of [email protected]? I can try to help.

    Have you tried to filter the records by the sale or purchase price is not equal to null column price?

    Thank you
    Bipuser

  • Link conditional branching to two different pages, based on another column

    Hello

    I have a sql report in which 1 column is a link. I want to link to two different pages depending on the value of another column.

    Example of

    the sql is

    Select a, b, c
    x;

    The link on column b must create a branch to the 500 page if c = 1 and on page 501 if c = 2.
    Is it possible to do? Thank you.

    Suni

    Can assign you points then accordingly...

    Thank you

    Tony Miller
    Webster, TX

  • update of column based on another column

    Hi all

    I want to update the column 2 of the table based on the value of update in column 1 and the existing value in column 1

    Assume that table1 has columns ID, col1 and col2

    I update col2 based on the update to col1 value and comparing the existing value of col1 in the table.

    trying to decode, I think it should work.

    Thank you.

    Not like that.

    You change a column of type CHAR, VARCHAR2 column, right? Thus, the data will be same. (Completed with space). For the new data inserted into a column VARCHAR2 TRIM is not necessary.

  • Comparison of the conditional formatting to another column

    All,

    I wonder if there is a way to compare to another column in the comparison of the conditional formatting? I have two columns, one which is the original value and another which is a return entry that starts with the original value, then changes. Is it possible to compare the two in the conditional formatting, and then say so bold or in italics the original version back writing change? I tried to use SQL and the format of the column as it is on the report and it does not accept whatever it is, it says that "the value entered is not valid."

    Thanks in advance,

    Josh

    Why not add a column that performs the comparison, hide this column and to sit the formatting of the column (you want to format) on the value of the hidden column?

    Kind regards
    Stijn

  • Numbering of the lines based on two columns

    Hello world

    I´d would like to know if there is a way to achieve the numbering shown in the second table below indicating only Oracle native functions, like ROW_COUNT() on the partition, etc.

    I m using Oracle 10 g.

    The logic used is:
    From 1, increment one each time that the ORIGIN is identical to the FIRST ORIGIN of the line (ID) group.
    ID    ORIGIN    DESTINATION    ORDER
    ------------------------------------
    1     A         B              1
    1     B         A              2
    1     A         B              3
    1     B         C              4
    1     C         A              5
     
    ID     ORIGIN    DESTINATION    ORDER    NUMBERING
    --------------------------------------------------
    1      A         B              1        1
    1      B         A              2        1
    1      A         B              3        2
    1      B         C              4        2
    1      C         A              5        2
    In order to compare the ORIGIN of each line with the FIRST ORIGIN of the group, I used the function LAG to create a column that will be the FIRST ORIGIN of the value in the group.

    However, I was not able to number the lines as shown above (column NUMBERING).

    Any help will be much appreciated.

    --------------------------------------------------------------------------------------------------------------

    Test query:
    WITH T AS
    (
      SELECT 1 ID, 'A' ORIGIN, 'B' DESTINATION, 1 ORDERING FROM DUAL UNION ALL
      SELECT 1 ID, 'B' ORIGIN, 'A' DESTINATION, 2 ORDERING FROM DUAL UNION ALL
      SELECT 1 ID, 'A' ORIGIN, 'B' DESTINATION, 3 ORDERING FROM DUAL UNION ALL
      SELECT 1 ID, 'B' ORIGIN, 'C' DESTINATION, 4 ORDERING FROM DUAL UNION ALL
      SELECT 1 ID, 'C' ORIGIN, 'A' DESTINATION, 5 ORDERING FROM DUAL
    )
      SELECT T.ID
           , T.ORIGIN
           , T.DESTINATION
           , T.ORDERING
           , LAG (T.ORIGIN, T.ORDERING -1, 0) OVER (PARTITION BY T.ID
                                                        ORDER BY T.ID
                                                               , T.ORDERING) FIRST_ORIGIN_OF_GROUP
        FROM T
    ORDER BY T.ID
           , T.ORDERING

    Hello

    Here's one way:

    WITH     got_first_origin     AS
    (
         SELECT     id, origin, destination, ordering
         ,     FIRST_VALUE (origin) OVER ( PARTITION BY  id
                                          ORDER BY         ordering
                                     ) AS first_origin
         FROM    t
    )
    SELECT     id, origin, destination, ordering
    ,     COUNT ( CASE
                        WHEN  origin = first_origin
                  THEN  1
                    END
               )     OVER ( PARTITION BY  id
                           ORDER BY      ordering
                   ) AS numbering
    FROM     got_first_origin
    ;
    

    This assumes that the combination of id and order is unique. Within an id, you place your order does not have to be consecutive integers, or something like that.

    Analytical functions cannot be nested (the argument of the function of COUNTY anlytic can not call the analytical FIRST_VALUE function); The subquery is necessary.
    You could do something with a LAG, as you have tried, rather than FIRST_VALUE, but you would still need a subquery, for the same reason.

Maybe you are looking for

  • MS 2100 "dead" after the restart - only 2 lights "

    I rebooted my Satellite Pro 2100 and waited for it to power upward again. But it does not. It is fairly new, 1 year old. I pressed the button, but the machine stays dead. The more good led-light will turn on for a second and then turns off again. No

  • Installing XP on Satellite P200 (PSPB3)

    Hi all I'm trying to install XP Pro SP2 (unattended) on my laptop of neighbors. He recently bought it 2nd hand with Vista Home installed. The installation program recognizes the HARD drive (without having to install the SATA drivers?!), so I formatte

  • question of charge iPhone 6s

    Can someone give me some answers on the most successful, or an effective way to load my new iPhone 6s straight out of the box, in order to maximize or extend as much as possible the battery life?

  • The upgrade of the x 51 Alienware

    So I thought to upgrade my alienware x 51 (Version of 645 GTX w / 180 Watt power supply) and was thinking about upgrading to this card ZOTAC NVIDIA GeForce GTX 750 Ti 2 GB GDDR5 2DVI/Mini HDMI PCI - Express graphics ZT-70601-10 M I was cool the card

  • The samples and the Simulator

    Of course miss me configuration here but something despite the (active) configuration and create a simulator, I run as application Tablet and I get Package failed: 1Error: File or dir does not exist: C:\apps\bbndk-2.0.0-beta1\target\target-override\x