How do I select a row from the middle of a recordset?

UserID QuestionID Answered
10 9 N
10 8 N
10 7 N
10 6 N
10 5 Y
10 4 Y
10 1 Y
From the table sorted by QuestionID DESC, how do I select the first row from the bottom going up with Answered value equal to 'N'?
Which in the example above would be:
10 6 N
I need to select this row and get the QuestionID value equal to 6.
Right now I have:
select QuestionID
from tblMap
where Answered = 'N'
and ROWNUM = 1
order by QuestionID ASC;
This always the top most row, which would be:
10 9 N

Here i used DUAL to generate a list of numbers for me.
ME_XE?select *
  2  from
  3  (
  4     select row_number() over (order by col1 desc) as rn, count(*) over() as cnt, col1
  5     from
  6     (
  7        select level as col1 from dual connect by level <= 9
  8     )
  9  )
10  where ceil(cnt/2) = rn
11  /
                RN                CNT               COL1
                 5                  9                  5
1 row selected.
Elapsed: 00:00:00.07
ME_XE?Edited by: Tubby on Jul 8, 2009 1:47 PM
Seems i misread the question :)

Similar Messages

  • How to add A single row at the middle of the table in a Webi report

    Hi,
         I created a Webi report using Universe(Created universe using bex query).Now i have a requirement to display a row at the middle of a report. Can you please tell me ,how to add a sigle row at the middle of a Webi report.
                                                    Thanks in advance
    Regards
    Monika

    Hi Monika,
    It is not really possible to add a row (I assume you mean of unrelated data) to the middle of a table in a report. You can add a new table with a single row between two tables. For instance you could add a new one row table, or even single cells which are positioned relatively between two tables. Possibly a block on top of another. But this gets tricky.
    Can you explain in more detail what you are trying to do?
    Thanks

  • How to insert a new row in the middle of an set of rows

    Hi
    How to insert a new  row in the middle of an set of rows ? and How to Reset the line id after the new row added ?
    Regards,
    Sudhir B.

    Hai,
    just try this,
    Instead of using omatrix.Addrow(1,-1) use like
    omatrix.AddRow( RowCount , Position)
    RowCount
    The number of rows to add (default is 1)
    Position
    The position of the new rows (0-based; default is -1, meaning append row to the end)
    After adding rows in matrix For, sno.
    for i=1 to omatrix.visualrowcount
    otext=omatrix.getcellspecific("columnid",i)  '--where columnid is the unique id of the sno column
    otext.value=i
    next i
    Hope this helps you.
    Thanks & Regards,
    Parvatha Solai.N

  • How can i select some row from multiple row in the same group of data

    I want to select some row from multiple row in the same group of data.
    ColumnA        
    Column B
    1                  OK
    1                   NG
    2                   NG
    2                          NG
    3                          OK
    3                          OK
    I want the row of group of
    ColumnA if  ColumnB contain even 'NG'
    row , select only one row which  Column B = 'NG'
    the result i want = 
    ColumnA         Column B
    1                         NG
    2                   NG
    3                          OK
    Thank you

    That's some awful explanation, but I think this is what you were driving at:
    DECLARE @forumTable TABLE (a INT, b CHAR(2))
    INSERT INTO @forumTable (a, b)
    VALUES
    (1, 'OK'),(1, 'NG'),
    (2, 'NG'),(2, 'NG'),
    (3, 'OK'),(3, 'OK')
    SELECT f.a, MIN(COALESCE(f2.b,f.b)) AS b
    FROM @forumTable f
    LEFT OUTER JOIN @forumTable f2
    ON f.a = f2.a
    AND f.b <> f2.b
    GROUP BY f.a

  • Fetching a partial range of selected result rows from the client side

    It has been a while since I started trying to solve this Oracle puzzle.
    Basically, what I need it is a way to fetch from the client side a run-time
    defined range of result rows of a arbitrary SELECT query.
    In low-end databases like MySQL I can do it simply by appending the LIMIT
    argument to the end of the SELECT query statment passing the number of
    the first row that I want to be returned from the server from the total
    result rows available in the result set and the maximum number of rows
    that it may return if available.
    In higher end databases I am supposed to use server side cursors to skip
    any initial rows before the first that I want to retrieve and fetch only
    the rows I want up to the given limit.
    I am able to achieve this with PostgreSQL and Microsoft SQL server, but I
    am having a hard time with Oracle. The main problem is how do I fetch
    result rows from a server side cursor and have their data returned to a
    client side in a result set like in a straight SELECT query?
    I was able to create a cursor and fecth a row into a server side record
    variable with the following PL/SQL code.
    DECLARE
    CURSOR c IS SELECT * FROM my_table;
    my_row c%ROWTYPE;
    BEGIN
    OPEN c;
    FETCH c INTO my_row;
    CLOSE c;
    END;
    I want to do this from PHP, so I don't have client side ESQL variables to
    store the result set data structure. Anyway, if I can do it just with
    SQLPlus I should be able to do it in PHP.
    If I do straight SELECT I can get the result set, but in a PL/SQL script
    like the one above I don't seem to be able to select the data in the
    fetched row record to have returned to the client. Does a straight SELECT
    query sends the result rows to a default client side variable?
    If anybody can help, I would appreciate if you could mail me at
    [email protected] because I am not able to access this forum all the time in
    the Web. BTW, is it possible to access this forum by e-mail?
    Thanks in advance,
    Manuel Lemos
    null

    Hello Jason,
    On 03-Feb-00 05:34:14, you wrote:
    I'm not sure I totally understand your problem, but I think you might be able
    to solve it by using the ROWNUM variable. ROWNUM returns the sequenc number
    in which a row was returned when first selected from a table. The first row
    has ROWNUM = 1, the second has ROWNUM = 2, etc. Just remember that the
    ROWNUM is assigned as soon as it's selected, even before an order by. So if
    you have an order by clause, it'll mess it up. Here's an example. I hope
    that helps.I though of that before but it doesn't help because if you use ORDER BY the
    first result row might not have ROWNUM=1 and so on. Another issue is that
    I want to be able to skip a given number of result rows before returning
    anything to the client.
    The only way I see to do it is to get the rows with server side cursor.
    But how do I return them to the client? Where does a normal select returns
    the rows? Isn't there a way to specify that the fetch or something else
    return the rows there?
    Regards,
    Manuel Lemos
    Web Programming Components using PHP Classes.
    Look at: http://phpclasses.UpperDesign.com/?user=[email protected]
    E-mail: [email protected]
    URL: http://www.mlemos.e-na.net/
    PGP key: http://www.mlemos.e-na.net/ManuelLemos.pgp
    null

  • How do I remove a row from the database?

    Guys and Gals,
    I'm using Studio Edition Version 11.1.1.3.0.
    The code below will delete a row from my table, but how do I actually delete the row from the database as well?
        DCBindingContainer dcbc = (DCBindingContainer)getBindings();
        DCIteratorBinding dcib = dcbc.findIteratorBinding("TipsSelectorIterator");
        dcib.removeCurrentRow();
        BindingContainer bindings = getBindings();
        OperationBinding operationBinding = bindings.getOperationBinding("Commit");
        Object result = operationBinding.execute();
        AdfFacesContext adffacesctx = AdfFacesContext.getCurrentInstance();
        adffacesctx.addPartialTarget(this.getQueryTable()); In this post, I believe Frank sums up what I should do: Remove row from af:table
    >
    The problem in your case is that this removes the row from the iterator but not your business service. EJB exposes explicit methods to remove an entity. A method lime removeEmployees(employee) >expsed on the EJB model must be called.
    You can drag and drop the "removeEmployees" method then as a button to your page. Rename the text label to "Remove" or "Delete". In the opened dialog box, point the method argument to the >following EL #{bindings.iteratorName.currentRow.dataProvider}. Next time you press the button, the row is deleted from the iterator and the business service
    Huh? So to delete the row, I need to expose a method. But where? Do I do this in the AppModuleImpl so I can expose it to the Client Interface? But then how do I access entities? And what data type is the #{bindings.iteratorName.currentRow.dataProvider}?
    If anyone could point me in a general direction, it'd be great.

    Frank and Shay,
    Thank you both for your posts. I'm amazed there's such a great place to get help. Between the forums, ADF code corner, Not Yet Documented ADF Samples, various blogs and tutorials, it's obvious you guys really care about what you do.
    On my example, that approach doesn't seem to work. I tried following it like so in one of the video tutorials by Shay: http://blogs.oracle.com/shay/2010/04/doing_two_declarative_operatio.html. Following Shay's approach, in my particular case, deletes only from the table. Perhaps it is due to my iterator / collection setup?
    TipsSelector (1 to 1) -> TipsView (1 to *)-> DependentBom -(1 to * Recursive)> RecursiveBom
    TipsSelector references the same View Object as TipsView, but it is set as a 1 to 1 relationship so that I can show TipsView on the page one record at a time. This is the same setup as Tuhra2's hierarchy veiwer example. TipsView / DependentBom is a classic parent / child setup. RecursiveBom is DependentBom referencing itself. Think of it as departments within departments within departments etc...
    I have dragged TipsSelector's Named Criteria (All Queriable Attributes) onto my page and created an ADF Query with Table. A remove button on the table's toolbar calls the two actions, Delete (from TipsSelector's iterator) and then Commit. I have modified the code slightly from my previous post but the end result seems to be the same.
        BindingContainer bindings = getBindings();
        OperationBinding operationBinding = bindings.getOperationBinding("Delete");
        operationBinding.execute();
        bindings = getBindings();
        operationBinding = bindings.getOperationBinding("Commit");
        operationBinding.execute();
        AdfFacesContext adffacesctx = AdfFacesContext.getCurrentInstance();
        adffacesctx.addPartialTarget(this.getQueryTable());Page Def file
        <action id="Commit" InstanceName="AppModuleDataControl"
                DataControl="AppModuleDataControl" RequiresUpdateModel="true"
                Action="commitTransaction"/>
        <action IterBinding="TipsSelectorIterator" id="Delete"
                InstanceName="AppModuleDataControl.TipsSelector"
                DataControl="AppModuleDataControl" RequiresUpdateModel="false"
                Action="removeCurrentRow"/>On ppr of the query table, the row is gone. However, when I press the Search button on the query again, the record reappears.
    This is beyond me. Am I somehow deleting from the query results but not the database?

  • Randomly selecting some rows from the database table

    Hi can some one help me in selecting some rows from a database table which has around 90,000 rows.
    Thanks.

    One thing you might try is the "sample" clause if you have 8i which is supposed to return a random percentage of the table. Say for example, you have a sequence number on your table as the pkey. Then you might try:
    select * from <table_name> where pkey in(select pkey from <table_name> sample(10));
    This should give you a random 10 percent of the rows in the table but I tried this once and the results seemed unpredictable. For example it returned a different number of rows each time even though the number of rows in the table didn't change.
    Hope this works for you.

  • How to efficiently select random rows from a large table ?

    Hello,
    The following code will select 5 rows out of a random set of rows from the emp (employee) table
    select *
      from (
           select ename, job
             from emp
           order by dbms_random.value()
    where rownum <= 5my concern is that the inner select will cause a table scan in order to assign a random value to each row. This code when used against a large table can be a performance problem.
    Is there an efficient way of selecting random rows from a table without having to do a table scan ? (I am new to Oracle, therefore it is possible that I am missing a very simple way to perform this task.)
    thank you for your help,
    John.
    Edited by: 440bx on Jul 10, 2010 6:18 PM

    Have a look at the SAMPLE clause of the select statement. The number in parenthesis is a percentage of the table.
    SQL> create table t as select * from dba_objects;
    Table created.
    SQL> explain plan for select * from t sample (1);
    Explained.
    SQL> @xp
    PLAN_TABLE_OUTPUT
    Plan hash value: 2767392432
    | Id  | Operation           | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT    |      |   725 | 70325 |   289   (1)| 00:00:04 |
    |   1 |  TABLE ACCESS SAMPLE| T    |   725 | 70325 |   289   (1)| 00:00:04 |
    8 rows selected.

  • How to remove only one row from the database using labview6.1

    using labview 6.1 I create a table with various rows and columns and store bulk of data's in them.,, what procedure should I follow to remove only one paticular row from the database? Help me out with an example please,,
    Thanking you in advance!

    Hi,
    If you have the database toolkit you can delete a row using just a SQL Query to "DB Tools Execute Query.VI"
    Example:
    DELETE FROM Table name Where SerialNum='Value' And Date='Value' And Time='Value'
    See also attached VI
    Best Regards
    Johan
    Attachments:
    Delete_a_row_in_a_database_table.vi ‏48 KB

  • How can I select a colour from the colour 'wheel'

    I would like to be able to select a colour like you can in photoshop. The swatches are very limited. I would like to select it from the colour 'wheel', where you can move up and down the slider to select the value and then move over the circle to select your colour? Or where can I find a huge swatch of colours?
    Regards
    Jenny

    Jenny,
    How would the Color Picker suit you?
    You can DoubleClick the Fill or Stroke (hollow) square in the Toolbox or the Color palette.

  • How do you select multiple emails from the contacts book.

    Using 10.8.4. I would like to use mail and select multiple email address' from the contacts book to send the same message to multiple persons. I thought I used to be able to select more than one at a time from my contacts book. Am I crazy or did they change the way it works from the previous version of software.
    Or, could you go to the contacts book and email from there. Either way it seems like it was easy to do and now I have to select one at a time and keep going back to the contacts/address book for another name.

    Hi shelereric,
    Once you open a new message, you should be able to just start typing the first letters of the contact's name, and Mail should give you a dropdown to select from:
    So, you should not have to go back and forth between your contacts and mail....anyone in your address book should show up on the dropdown as well as anyone you have received emails from or sent emails to even if they are not in your contacts....
    Is that not what is happening for you? Are you using the Mail app on the Mac?
    Cheers,
    GB

  • How do I select a photo from the timeline to apply an effect.

    I am tryiing to select an individual photo on the timeline to apply an effect like a zoom or pan.

    Jules789
    I suspect your answer is for you to right click the video (your slideshow in video .psess format) now on the Premiere Elements 11 Expert workspace Timeline and then select and click on "Break Apart Elements Organizer Slideshow" command. The command will achieve that and you should be able to move forward with your editing plans.
    The above applies if these are the details of your workflow which I believe to be the case....
    1. In the Elements Organizer 11 Slideshow Editor you put together some photos and used the Slide Show Editor's Cross Dissolve transition in the Slideshow Editor slideshow.
    2. You outputted the slideshow from the Elements Organizer 11 Slide Show Editor using the Output option of Edit with Premiere Elements Editor.
    3. When you do that you will find in Project Assets, a folder with the projects assets as well as one copy of the slideshow as a video in .psess format. There will also be a copy of the .psess video on the Timeline.
    4. When you use that route, the Break Apart Elements Organizer Slideshow command is available to you in order for you to make additional significant edits to the slideshow before a burn to.
    If you use any of the Slide Show Editor options to create the wmv version of the slideshow (Burn to Disc or Save As A File Movie wmv), the file on the Timeline will be a whole video in wmv format. That cannot be broken apart with the Break Apart Elements Organizer Slideshow command.
    Please review my assumptions and speculations and let us know if the answer that I provided was appropriate under the circumstances.
    If not, lots more details please.
    Thanks.
    ATR

  • How to start midi event playing from the middle of event?

    I'm not sure if my post title is correct but...
    I have a two minute piece of music with various instruments playing.  There are some strings that play the same couple of notes throughout.
    At the moment I am working on a middle section but as I loop, the srings aren't triggered - I have to play from the start (before the event starts).  I did not have a problem with Cubase but I can't find a way to do this in Logic.
    It's probaly quit simple though?

    This typically means the midi notes themselves start before the beginning of the loop point you have choosen
    You can quantize or manually move the first notes so that they start at the beginning of the loop and not just before... to resolve this..
    Select the regions and then check the event list for the region to confirm this is what is going on...

  • How to learn and work CS6 from the middle of nowhere ?

    Hello all,
    I live along the cordillera de los Andes, and the first good internet connexion is 30 km away from my "casa de campo".
    Sooooooo, how do I do ?
    First question (thanks)
    1. I go to "town" with my (light) MacBook Pro and I load programs and updates.
    2. when home, I connect my MacBook Pro to the (heavy) iMac and I make the iMac updated this way.
    question : will it work if I buy CS6 on my MacBook Pro and "copy" it on my iMac ?  so one licence on two computers
    and I'll use one computer at a time.
    Second question (thanks for your patience)
    1. I am for the week in Buenos Aires with a  serious internet connexion I can buy CS6 from there and load it on my MacBook
    2. but there are so many tutorials that I would like to copy them all, go back to the middle of nowhere and start learning on my own
    question : if this is possible, how do I copy the tutorials ?
    Thanks for you patience, have a nice day
    Richard

    CS6 should still be available on CD/DVD as a suite. Amazon and other internet sites should still be selling it. That license is good for 2 computers, only 1 can run the suite at a time. But can stay installed on both.
    While looking at that site, search for tutorials on CD. Get a few books as well, which are also available as ebooks or kindle books. The kindle software is free for most systems including windows and Mac.
    The CC or cloud version probably would not be for you unless you can make sure you can get to an internet connection once a month. Though if you can not don't worry the software will reactivate the next time you connect.
    Good luck...

  • How do I delete a clip from the middle of a scene

    Trying to delete a clip from a scene in the middle of a movie.
    The trim option only seems to let you keep what you want but won't delete what you don't want.

    The choices you mention only appear when in the Event and perform what AppleMan has described. You need to do the edit in the Project. Following AppleMan's advice, you will see this pop-up menu:
    The project simply references the video clips in the associated Event. Deleting the selection from the project will not remove the video from the Event, but will just extract that portion from the clip in the project, as AppleMan described.
    John
    PS Oops! Beaten to the punch by AppleMan!
    Message was edited by: John Cogdell - added PS

Maybe you are looking for

  • Stolen macbook pro - gmail syncing question

    Hi, My macbook pro was stolen from my apartment at the weekend - sometime between Saturday morning and Monday evening. Unfortunately I do not have 'findmymac' or anything enabled. Knowing the time that the thief got into the apartment would make it m

  • Error type 10 with Agfa Snapscan USB Scanner

    I'm getting an error type 10 whenever I try to start ScanWise, the software that comes with an Agfa SnapScan 1212u. I've tried reinstalling the software, extensions, etc. I've also reset PRAM. Help!

  • Image Capture Error Message Import Error -9912

    Hi I was backing up the photos and videos from my iPhone 5s to an external hard drive that I have. I have done this many times before without a problem. Today, I encountered an error. It said "Import Error (-9912)" and 1,025 items were not imported.

  • Is it possible to add tags to files with Adobe Reader?

    Hi, I scan many of my hand-written notes from meetings during my work day.  I would love to be able to assign a few tags to the file so that I can find them easier with file searches (in Windows) in the future, without having to put every key word in

  • Update_SM-N900V_MJ7_to_MJE - 402 fails with error code 402

    The update always fails with the error code 402.   Anyone else having the same issue? Thanks.