Limit the number of results from a querying a table

I have a table, NAMES, that holds appx 50 names.
I want to be able to list a certain amount of names and once that limit is reached( 6 or 7 or so), output a row / link / statement that says, you've reached your limit.
For example the output would look similar to :
Jim
John
James
Mike
Henry
Mark
'Limit Reached'
'Limit Reached' would eventually need to be a link, but I am already familiar with creating links from query results, persay.
I've experimented with listagg, case statements and decode but am not sure how to do this. I'm thinking decode is the way to go but am not sure how to keep track of a counter as the sql is running. This needs to be written in sql only, not pl/sql, if possible. My query so far is
Select first, last
From Names
where rownum <= 6
Not sure how to accomplish this. Any help would be greatly appreciated. Thanks in advance

Hi,
NewApexCoder wrote:
@FrankKulasg
I have tested these using union. However, I also have columns I need to include that aren't text fields (such as an ID column, which is a number / integer type). I can't use NULL. Is there anything to substitue for this?
Other people can use NULL.  Why can't you?
If you could use NULL. then you could do something like this:
SELECT  ename
,       job
,       sal     -- a NUMBER column
FROM    scott.emp
WHERE   ROWNUM  <= 6
    UNION ALL
SELECT  'Limit reached'
,       NULL    -- in place of a VARCHAR2
,       NULL    -- in place of a NUMBER
FROM    dual
Output:
ENAME         JOB              SAL
SMITH         CLERK            800
ALLEN         SALESMAN        1600
WARD          SALESMAN        1250
JONES         MANAGER         2975
MARTIN        SALESMAN        1250
BLAKE         MANAGER         2850
Limit reached
7 rows selected.

Similar Messages

  • Pagination Limit the number of result from query. If exceed throw error

    Hi expert,
    I have a question that need your guidance.
    Declare
        type myarray is table of emp.empid%type;
        mytab myarray;
        vcounter number;
        vlimit number;
    Begin
        select limitnumber into vlimit from ABC where table_name = 'XYZ';
        select count(*) into vcounter from emp where empid = 1 /*let say this return 5500 records and take 10 seconds*/
        if vcounter > 5000 then
           raise_application_error(-20010,'you will process more than allowed number of record');
        else
            select empid bulk collect into mytab where empid = 1; /*let say this will take another 10 seconds for 5000 records*/
        end if
    End;
    /as you see there, if I want to insert 5000 records it will take me 10 sec to count first and then another 10 sec to insert.
    I am trying to avoid the count to save time, but how to limit if the array insertion to 5000 otherwise throw the error.
    please note that we limit the limitnumber in table ABC and that can be changed.
    thanks
    Henk
    Edited by: user9180414 on Oct 19, 2011 12:57 PM

    If you want to select just first 5000 rows use LIMIT:
    select empid bulk collect into mytab limit 5000 where empid = 1;If you also want to make sure there is no more than 5000 rows use:
    select empid bulk collect into mytab limit 5001 where empid = 1;
    if mytab(5001). exists then
    raise_application_error(-20010,'you will process more than allowed number of record');
    end if;SY.

  • Nepomuksearch - How to limit the number or results

    Hello,
    I use nepomuksearch for several versions of kde now.
    Until now, we could limit the number of results in systemsettings.
    Since switching to kde 4.10, it is no longer possible: this parameter does not exist in the systemsettings. We can not further limit the number of results.
    Is there a way to limit the number of results in nepomuksearch, and if so, how?
    Thank you very much for your help.

    Hi,
    If not set explicitly, the default value for WILDCARD_MAXTERMS is 5000. This is set as a wordlist preference. This means that if your wildcard query matches more than 5000 terms the message is returned. Exceeding that would give the user a lot to sift through.
    My suggestion: trap the error and return a meaningful message to the user indicating that the search needs to be refined. Although it is possible to increase the number of terms before hitting maxterms (increase wildcard_maxterms preference value for your wordlist), 5000 records is generally too much for a user to deal with anyway. The search is not a good one since it is not restricting rows adequately. If it happens frequently, get the query log and see the terms that are being searched that generate this message. It may be necessary to add one or more words to a stoplist if they are too generic.
    Example: The word mortgage might be a great search term for a local business directory. It might be a terrible search term for a national directory of mortgage lenders though (since 99% of them have the term in their name). In the case of the national directory, that term would be a candidate for inclusion in the stoplist.
    Also remember that full terms do not need a wildcard. Search for "car %" is not necessary and will give you the error you mentioned. A search for "car" will yield the results you need even if it is only part of a bigger sentence because everything is based on the token. You may already know all of this, but without an example query I figured I'd mention it to be sure.
    As for limiting the results - the best way to do that is to allow the user to limit the results through their query. This will ensure accurate and more meaningful results for them.
    -Ron

  • HT2729 I have limited space on my new ipad. How can I limit the number of songs from my itunes on my imac from going to my ipad when I connect the two?

    I have limited space on my new ipad. How can I limit the number of songs from my itunes on my imac from going to my ipad when I connect the two?

    you can do this by keeping the external hard drive connected and doing the following
    -hold shift key down on computer while opening iTunes and a prompt will appear to choose a library
    -select choose library, iTunes should bring up your explorer windows where you can search for the external HD
    -after you find the external HD find the iTunes folder you just copied to it
    -after opening the iTunes folder look for the file that says iTunes library.itl or if you can't see that extenstion just look for a document looking thing in the iTunes folder that shows up as a database file
    -double click the database file and boom iTunes should load your library without having to copy it to the computer
    PS: do make sure that if you are going to do it this way, make sure that the external HD is connected at all times, because if you don't then you will get exclamation marks next to your iTunes songs
    double PS: if you are unsure how to find out if the iTunes library file is a database file just right click it and choose properties and under the type it should say database file
    hope this helps:)

  • How to limit the number of items from RSS using XSLT

    Hello,
    I am using plsql to read contents from RSS, basically a simple RSS reader.
    I would like to somehow want the feature to restrict the number of items in the RSS feed, say I would like to display only the first 5 items.
    How could I achieve this?
    Any help is highly appreciable.
    Thanks in advance.
    Regards

    Hi,
    According your post, I know you would like to set the item display limit in Status List web part.
    In the web part, the number of items to display is based on the view which you selected when configuring the web part. The default view for status list is status list view.
    However, I am not able to limit the items’ display number of the status list view. After changing the items limit, the list item displayed would not match the number specified by Item Limit. Thus, it is not possible to limit the number
    of items in the Status list web part.
    It could be a potential issue in SharePoint 2010.
    We will log this issue to our suggestion box. As after the submission, we may not have any time guarantee when the fix may be released, but it may come out on next cumulative update.
    Appreciate your time and efforts.
    Thanks.
    Tracy Cai
    TechNet Community Support

  • Getting number of results from mysql query.

    Hi,
    Is there an easy way to get the number of rows (results) returned by a mysql query without looping through each result and incrementing using the rs.next()?
    Statement statement = connection.createStatement();
                   ResultSet rs = statement.executeQuery("SELECT * FROM sometable WHERE name=\"John\"");
                   

    Have you looked at the mysql documentation at all ?
    What about "SELECT count(*) FROM sometable WHERE name=\"John\"");
    And if this value is going to be dynamic at all consider using a preparedStatement.
    Note Haven't worked with MySql so this isn't guarenteed to work, but you get the idea. This is more of a sql question than a java question

  • Is there is limit to the number of results from Address Book

    I am syncing with Exchange 2007, and when I use Address Book to search the Exchange GAL, I only ever get a 100 results. I have checked the same search on Windows and get more than 100 results. It would appear that Address Book has some sort of limit to LDAP searches in Address Book.
    Has anyone else seen this?

    You can create Matlab scripts with more than 4 outputs. Maybe if you could provide your script and the error message we can provide more insight into your difficulty.
    Marc

  • If my code displays a recordset, how can I limit the number of results to display?

    I have the code below:
    <div id="content">
        <table width="998" border="0" cellspacing="4" id="stuff">
            <?php do { ?>
              <tr>
                <td><?php echo $row_Recordset1['name']; ?></td>
    </tr>
    <?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
    </table>
          <div id="spryTable" spry:region="ds1">
            <table align="center">
              <tr>
                <th spry:sort="name"> </th>
              </tr>
              <tr spry:repeat="ds1" spry:setrow="ds1" spry:hover="hover" spry:select="selected">
               <td height="40" align="center">{name}</td>
               <td height="40" align="center">{name}</td>
              </tr>
              </table>
          </div>
    At the moment the green line prints the names in one column of a table, and the orange line prints the same list again.
    The problem is, I want half the names to be printed in one column and the other half of names to be displayed in the other column.
    Can someone show me how to set the php code to do this? I've been trying various things for a while now without success.
    Thank you.

    I am assuming that you have created a SpryHTMLDataSet from the table produced from the PHP-code.
    To display the result in two columns, use CSS as follows
    <!DOCTYPE HTML>
    <html xmlns:spry="http://ns.adobe.com/spry">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>Untitled Document</title>
    <script src="SpryAssets/xpath.js" type="text/javascript"></script>
    <script src="SpryAssets/SpryData.js" type="text/javascript"></script>
    <script type="text/javascript">
    var ds1 = new Spry.Data.XMLDataSet("employees.xml", "employees/employee");
    </script>
    <style>
    .RowContainer {
        width: 400px;
    .RowColumn {
        width: 50%;
        float: left;
    </style>
    </head>
    <body>
    <div spry:region="ds1">
      <div spry:repeat="ds1" class="RowContainer">
        <div class="RowColumn">{firstname} {lastname}</div>
      </div>
    </div>
    </body>
    </html>
    In the example above I have use a SpryXMLDataSet but the principle remains the same. The used XML file is as follows
    <?xml version="1.0" encoding="iso-8859-1"?>
    <employees>
        <employee id="123456">
            <lastname>Smith</lastname>
            <firstname>Edward</firstname>
            <joinDate>2009-10-01</joinDate>
        </employee>
        <employee id="127937">
            <lastname>Johnson</lastname>
            <firstname>Neil</firstname>
            <joinDate>2011-03-06</joinDate>
        </employee>
        <employee id="126474">
            <lastname>Williams</lastname>
            <firstname>Steve</firstname>
            <joinDate>2011-03-20</joinDate>
        </employee>
        <employee id="120585">
            <lastname>Jones</lastname>
            <firstname>John</firstname>
            <joinDate>2010-12-13</joinDate>
        </employee>
        <employee id="127493">
            <lastname>Brown</lastname>
            <firstname>Joe</firstname>
            <joinDate>2011-01-01</joinDate>
        </employee>
    </employees>
    Gramps

  • Best way to limit results from a query.

    I need to limit the number of results returned from the database to the first x rows. What I need is a database independant way to achieve this - i.e. I can't use LIMIT, TOP, etc. in my query.
    My question therefore is does statment.setMaxRows(x) restrict my results at the database level or my application's view to the database? I.e. will the complete SELECT * run within the database but the first x will be returned to the resultset, which could be quite a performance drain at db level. Or will this have the same effect as running a query SELECT TOP X FROM... which will be a much quicker query to run?
    Any help greatly appreciated!

    The best, and only fool proof way to limit results (rows, columns) from a query, and not waste database resources is to code your query so it only returns the rows and columns that you need. That might mean providing date ranges, sequence number ranges and all other WHERE criteria that can be used to filter the data to exactly what you need.
    There are ways to limit what is available to your Java program, but in most cases, the entire SQL must be completed before any results can be returned. The simplest example is; using the SORT command to get the data into the order you require, will first require that all rows be made available to the sort. The fact that you only want the top 5 rows doesn't matter to the DBMS because it cannot give them to you incrementally.
    Focus on getting your SQL as efficient as possible. If the SQL runs efficiently, you can use almost any of the JDBC commands to limit, list, cursor forward and backward, etc, without regard to their overhead.

  • Limit the number of records in result list cartridge

    Hi experts
    I want to use result list cartridge for displaying some products but also want to limit the returned results to some max records.
    Is there any way i can limit the number of results in result list cartridge?
    Thanks

    Results list has a 'recordsPerPage' property that will limit the number of records on the page.
    Are you looking to limit it at some other place?
    HTH,
    Pankaj.

  • Limiting Number of result in CMIS query

    Hi
    Can we limit number of results in CMIS query
    my query is
    SELECT * FROM ora:t:IDC:GlobalProfile WHERE ora:p:xRegionDefinition LIKE \'ALERTRD\'
    I want only most recent 2 alerts to be displayed.
    Thanks

    Hi dears,
    I have the same problem. I added a Content Presenter to my page in Jdev ide, not in runtime. And i need a query includes limiting the number of resluts.
    The thread is signed with "correct" but i can't see any solution. Can you help me please? How can i limit the number of results ?
    Regards,
    Erdo

  • How to use Results from Another Query for SAP BW universes

    Hi Everyone,
    I have two SAP BI universes.In my First universe I have Sales Doc no (dimension) and Orderqty (Measure) and in my second universe I have Sales Doc no(Dimension) and BillQty (Measure).
    Here in my first dataprovider I have 1200 rows of data and in second dataprovider I have 75,000 rows. The report should fetch only the BillQty details that matches to corresponding  Sales doc no in first data provider.
    I want to place all these fileds into a single report like as shown.
    (Datarpovider1)                (Datarpovider1)                    (Datarpovider2)
    *Sales Doc No*               Orderqty                           BillQty
    Here I am able to generate single report using merge dimension but it is leading to performance issues. I want to restrict the values at query level by passing the First dataprovider Sales doc no to second Data provider Sales doc number using Results from Anothery Query feature so that It can fetch only the matching records.
    I tried it but it was giving the follwing error:
    A filter contains a wrong value. You cannot run this query. (Error: WIS 00007)
    How Can I get rid of this error. Can we use Results from Anothery Query option for OLAP universe. Are there any limitation on it.
    All this I am doing in Webi Rich Client.
    Appreciate your help
    Thanks &in Advance
    Kiran Saka

    Hi Kiran,
    I think the filter has a wrong operand. For example, a filter with an empty constant, or a filter that deals with numeric values is defined with an alphanumeric value.Check out for this.
    Regards,
    Neeraj

  • Results from another Query - not available

    HI,
    My environment is Business Objects XI 3.1 SP2 Edge series , i have  below quereis with web Intelligence Reports
    1. not available  the functions/options  Results from another Query(Any) or Results from another Query(ALL) at Query Level.
    2. not getting list of Values for pronpt until i refresh values for prompt?
    Please suggest me is there any fix packs available for the same to availle that functionality.
    Best Regards,
    Reddeppa K

    not getting list of Values for pronpt until i refresh values for prompt?
    There is option called  "Automatic refresh before use"  for the object properties available in the universe designer.
    Please check the box for the object you are using for populating the list of values and export the universe.
    not available the functions/options Results from another Query(Any) or Results from another Query(ALL) at Query Level.
    There is a limitation for the query on query functionality that the both the queries can-not be from the OLAP universe.
    I guess the query which needs to be filtered should be built on universe from the relational data base.
    Regards,
    Rohit

  • How do you limit the number of rows return from query?

    How do you limit the number of rows return from query? Do all databases support this kind of feature?

    i think the standard is limit
    to get the top 30
    select * from mytable LIMIT 30;returns the first 30 rows
    also if you want a range
    select * from mytable LIMIT 10,30;returns 30 rows starting from 10
    this last one is useful for displaying ranges... something similar happens in these forums when viewing topics and messages

  • ABAP Query - Want to limit the number of records to 5

    I have a query based on a a table join (MKPF with MSEG) infoset. I want to limit the number of records to first five.
    How to deal with it?

    select data from tables using join and where conditions....into internal table....
    now move the first 5 records to second internal table and use them...
    or else in ur select statement u can use...
    select  data from tables <join condition> upto 5 rows.
    Message was edited by:
            Ramesh Babu Chirumamilla

Maybe you are looking for

  • Pie Chart in WEBI is Grey color

    Hi All, As part of my project requirement I need to develop a WebI report with Table and Pie chart.I selected the pie chart, intially it was in grey color and assigned the data to chart .When I tried to change the color of the chart it is not display

  • Crystal report viewer do not show on client computer installation

    hi hope all you are fine i develop a simple project that show "Hello word My First Crystal Report" on crystal report viewer. after this i add new project "setup and deployment". In Setup Project I add 4 files of .msm for show crystal report. 1. CRRun

  • How to display the my_amount as 1,234.56 in my_amount column of my_alv?

    Hi Experts, Pls. clarify me that, Am getting my_amount values as 3456.78 as CHARs in my_ALV report. I wanna show them as--> 3, 456.78 in my_ALV report. I tried with MOVE my_amonut TO TYPE_P_DECIMALS_2_my_amount, but, in EUROPE am getting DUMP. So, I

  • TS3212 While trying to update my itunes, I have know uninstalled and am experiencing error messages

    I tried to updatemy itunes and now I am getting error message Run Time Error Progra:C:\ProgramFiles\(x86)\iTnes\iTunes.exe. I have uniinstalled and reinstalled multiple times and recieve this message.

  • Robohelp 10 command line crashes

    I am trying to build a robohelp project at the command line and it crashes. Building manually in the IDE works. The event log show: Faulting application name: RHCL.exe, version: 0.0.0.0, time stamp: 0x4ff35c65 Faulting module name: HtmSingleSourceMul