How to split a result set into n-number ranges, each range has same max-min

Hi guys,
suppose there's a table T1(fvalue number),
we can easily get the MAX and MIN of fvalue, for example, 19 and 5, I need to split them into, for example, 3 ranges, 5-9, 10-14, 15-19, they have the same max-min. And for each range, I need to know the count of rows that fall into this range.
does anyone have any clues? is there any analytic function i can use to accomplish this?
many thanks.

There are the NTILE and WIDTH_BUCKET functions that may be of use. However, I'm not exactly sure what you are after.
It is always helpful to provide the following:
1. Oracle version (SELECT * FROM V$VERSION)
2. Sample data in the form of CREATE / INSERT statements.
3. Expected output
4. Explanation of expected output (A.K.A. "business logic")
5. Use \ tags for #2 and #3. See FAQ (Link on top right side) for details.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

Similar Messages

  • How can we generate result set report?

    how can we generate result set report ?means the out put of one query be the input of another query?how it is?

    Hi
    You have to use APD ( analysis process designer) to use results of one query as the input for the other queries.
    Check this link
    http://help.sap.com/saphelp_nw70/helpdata/en/49/7e960481916448b20134d471d36a6b/frameset.htm
    Regards

  • How to handle large result set of a SQL query

    Hi,
    I have a question about how to handle large result set of a SQL query.
    My query returns more than a million records. However, the Query Template has a "row count" parameter. If I don't specify it, it by default returns only 100 lines of records in the query result. If I specify it, then it's limited to a specific number.
    Is there any way to get around of this row count issue? I don't want any restriction on the number of records returned by a query.
    Thanks a lot!

    No human can manage that much data...in a grid, a chart, or a direct-connected link to the brain. 
    What you want to implement (much like other customers with similar requirements) is a drill-in and filtering model that helps the user identify and zoom in on data of relevance, not forcing them to scroll through thousands or millions of records.
    You can also use a time-based paging model so that you only deal with a time "slice" at one request (e.g. an hour, day, etc...) and provide a scrolling window.  This is commonly how large datasets are also dealt with in applications.
    I would suggest describing your application in more detail, and we can offer design recommendations and ideas.
    - Rick

  • How to Split Single Outbound Idoc into Multiples

    Hi guys
    Hope you all are doing good.
    Can you please let me know , How to Split Single Outbound IDOC into multiples.
    I am looking for some sought of configuration in IDOC/from SHIPMENT Configuration level.  Because this needs to be implemented for Shipment IDOCS.  Please let me know if this can be done through configurations apart from implementing  User exit or copying the outbound shipment function module.
    Awaiting for your valuable replies.
    Best Regards
    Shiva

    Hello,
    1. Routes
    2. Packaging used
    3. Shipment Type
    Regards
    Waza

  • Convert result set into input stream

    Hi,
    I have result set with me having 93 columns with 1 lac rows. I want to download the result set as xls file.
    Because of the data set size is large, i'm not able to hold the data in java object. So i'm trying to convert result set to input stream and giving this input stream to servlet output stream by specifying the contentType as text/xls.
    I'm not able to convert result set into input stream.
    Could you provide a solution here...
    Thanks,
    Rajesh

    1 - JDBC is the wrong way to extract this data. It's like "What's the fastest way
    to copy the Oxford English Dictionary using tweets?" I would research the
    DBMS's bulk extract functionality.
    2 - Are you dead-set absolutely sure you need to do this at all? What can you
    do with the data all in one flat file that you cannot do with SQL access to the
    data?
    3 - If you want to convert all the columns into one (not that it's a huge
    win or anything), you can use the DBMS's conversion and concatenation
    functionality in your SQL. So instead of
    "select col1, col2, col3, .... from MyBigTable"
    do (change this to whatever conversion function syntax and concat syntax your DBMS needs)
    "select convert(col1, varchar) concat ' ' concat convert(col2, varchar) concat ' ' concat convert(col3, varchar) ... from MyBigTable"
    so the result set you get is a single column.
    Joe

  • How to split the IDOCS based on document number change whit out BPM

    Hi all,
    Thanks,for giving the responce..
    Scenario:File to IDoc.
    Problum1 : How to Split the IDocs based on document number change in the source file with out BPM.My file contains document numbers like
    20000092
    20000092
    20000092
    50000050
    50000050
    50000065
    I want 3 IDocs in target system.i.e 1 for 20000092,20000092,20000092
                                                       2 for 50000050,50000050
                                                       3 for 5000006
    By using external definations i am getting 6 IDOCs insted of 3.
    Problum 2:Is there any chnges/modifications in Directory when we are using external definations.
    Could u plz provide me the step by step process(Repository/Directory) with using of external definations.
    Thanks in advance.
    Regards,
    KP

    HI,
    for this no need of BPM.
    You can think of Idoc bundling concept to acheive this-just you need to do the external definition to change the idoc occurence
    /people/michal.krawczyk2/blog/2005/12/04/xi-idoc-bundling--the-trick-with-the-occurance-change
    to achieve for each document no, one idoc, you can write small user defined function in the mapping with context handling you an achieve this.
    For this e.g
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/6bd6f69a-0701-0010-a88b-adbb6ee89b34
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/877c0d53-0801-0010-3bb0-e38d5ecd352c
    Regards,
    Moorthy

  • How do i go about deleting a large number of files at the same time?  where's the easiest place to do it?

    how do i go about deleting a large number of files at the same time?  where's the easiest place to do it?

    A bit vague as to what you intend, but the simple answer is to select all the files you want to delete then either drag to the Trash or CTRL- or RIGHT-click on the selection and choose Move to Trash from the contextual menu.

  • How to cancle the previous apple ID and creat another one for the same ipad mini

    Please advise how to cancle the previous apple ID and creat another one for the same ipad mini.
    Thank you.

    You can log out of an account (you can't 'cancel' an account) by tapping on it in Settings > iTunes & App Store - any content that you downloaded with that account will remain tied to that account. You can then create a new account via the Create New Apple ID button on that screen. If you don't want to give credit card details then follow the instructions on this page when creating the new account : http://support.apple.com/kb/HT2534

  • How to Split java.util.Set object into multiple objects?

    Hi All,
    I'm having a collection of items in a Set. Assume that i'm having 10,000 items in Set A.
    Now i like to split the Set into multiple Set or Array such as each set or array consist of 100 records. i.e whenever
    i get more items i want to split them into mutiple set or array.
    Is there is any Java Api doesn't this function? or any other way to achieve this?
    Thanks,
    J.Kathir

    Iterate through them, placing them into different new collections.
    It may be easier to add the Set to a List, and then call sublist() a few times on the resulting List.

  • How to split a PE1 project into two smaller projects?

    I have a 1hr 36 min. project in PE1.  I want to split it into two different projects of about 48 min. each and burn two DVDs.  My intent is to get a better MPEG resolution for these smaller projects.
    Can I select half of the timeline, cut it and paste it into a new project?  Would the effects be preserved?  I have a week of work invested in this project and I don’t want to screw it up!
    Thanks
    Fred J.

    FredJ,
    Welcome to the forum.
    I agree with both Neale and Steve, though it might at first appear that they are saying two different things.
    The bit-rate in the Transcoding to MPEG-2 will be determined by the Duration of the Timeline and the capacity of the blank media, whether DVD-5, or DVD-9. In most versions of PrE, this bit-rate will be a function of the Quality Slider, but the ultimate bit-rate for the combined video and audio is set in the DVD-specs. One cannot exceed about 8 b/s.
    Now, with your Duration, there might be a very slight increase in the bit-rate, were you to take Neale's advice and break your Project into two parts, however, I think that his advice to study the result of your entire Timeline is good, as I doubt that one could tell the differences, unless you have a great deal of fast motion, of either the camera, or the subject, and then it's likely that the quality would appear to be the same to the human eye.
    Steve is correct in that the result will have to be within the DVD-specs, and will only be 720x480, at up to that max. bit-rate. That is as good as it gets.
    For the ultimate test, I would take Neale's suggestion on Burning to Folder one step further. Once that is done, you can first test your Project with a DVD software program on your computer. BUT, be aware that you are viewing on a higher-rez, progressive computer monitor, and its rez will exceed that of a TV and that of a DVD-Video disc. Thus, it is not a perfect test. To get an idea of how the DVD will look on a set-top player, hooked to a TV, you can either, also burn to a DVD RW (rewritable disc) to test on a set-top player, or you can use the free burning utility, ImgBurn, to burn to a DVD RW and test. The reason for the Rewritable media is so that you can reuse it for testing. You will NOT be using this disc for delivery, but just for testing. Now, if you feel that very slight decrease in bit-rate is noticed, you can go back to his suggestion on how to split the Project, and then produce a multi-disc. set for the Project.
    Also, the ultimate quality and also playability of the DVD-Video will be enhanced if you use quality blank media. I strongly recommend Verbatim, or Taiyo Yuden blank media. Brands like Memorex, TDK, recent Ritek and ALL "store-brands," are to be avoided. One is also best served by buying slower speed media, as PrE will measure the speed of the media and the speed of the drive and try to get you the fastest possible burn. It does not allow you to set the speed of the burn manually. Most people feel that stepping down from a max. burn speed produces a better DVD. I routinely will drop the burn speed (in other software) to about 1/2 of the max., and have had thousands of perfect DVD's. One can set the burn speed in the above mentioned ImgBurn utility.
    To distill the above: try it and see if your Project isn't perfect now, and if not, then break it apart into two segments. I doubt that you could tell the difference.
    Good luck,
    Hunt

  • Put database result set into a vector?

    I have a resultset rs I would like to put into a vector but I don't seem to get something fundamental. I can put individual items in with add() for instance but how do I dump a whole result set in there...
    and if I do so should I turn them all to strings before putting them into the vector?
    Any general advice would be appreciated, I've read a lot about Vectors today and have ended up more confused than I'd have expected. So I have come to seek some basic advice.
    private static void showResult (ResultSet rs) throws SQLException {
                            Vector vector = new Vector();
             try
                     // rs is the resultset output from a database
                                      vector.addAll(rs);
             catch(NullPointerException ex)
                    System.out.println("bugger - null pointer exception");
                    System.out.println();
                    ex.printStackTrace();
    }

    Iterate over the resultset, create your own object to store data for each row and add that object to the vector. There is no escape from this.
    catch(NullPointerException ex)You should not be handling Runtime exceptions. You need to take care not to let them occur through your coding logic.

  • How to execute entire result set of multiple sql statements via sp_executesql?

    I have a query that generates multiple insert statements (dynamic sql).  So when I execute this my result set is a table of sql insert statements (one insert statment per row in my source data table).  Like so:
                 Select 'INSERT INTO [dbo].[Table_1] ([Col1]) VALUES (' +  SrcData + ')' from SourceDataTbl
    How can I completely automate this and execute all these sql statements via sp_executesql?
    My plan is to completely automate and execute all this via an SSIS package.
    As always any help is greatly appreciated!
    fyi-  This is a very simple version of what I am trying to do.  My query probably plugs in 20+ values from the SourceDataTbl into each of the sql insert statements.

    Ah, a small error in Visakh's post, which I failed to observe, and then I added one on my own.
    DECLARE @SQL Varchar(max)
    SELECT @SQL =
       (SELECT 'INSERT INTO [dbo].[Table_1] ([Col1]) VALUES (' +  SrcData +
                ')' + char(10) + char(13)
        from SourceDataTbl
        FOR XML PATH(''), TYPE).value('.', 'nvarchar(max)')
    EXEC sp_executesql @SQL
    Without ", TYPE" FOR XML returns a string when assigned to a variable. The TYPE thing produces a value of the XML data type, so that we can apply the value method and get string out of the XML.
    And why this? Because:
    DECLARE @str nvarchar(MAX)
    SELECT @str = (SELECT 'Kalle Anka & co' FOR XML PATH(''))
    SELECT @str
    SELECT @str = (SELECT 'Kalle Anka & co' FOR XML PATH(''), TYPE).value('.', 'nvarchar(MAX)')
    SELECT @str
    Although the data type is string when , TYPE is not there, it is still XML and characters special to XML are enticised.
    Confused? Don't worry, for what you are doing, this is mumbo-jumbo.
    Erland Sommarskog, SQL Server MVP, [email protected]

  • Can I retrieve a result set from Oracle and then incorporate that result set into my main SQL Server Stored Procedure?

    So I have a chunk of data that only resides in Oracle. So I need to capture that information from Oracle. Now before you get over zealous, I did try with an OPENQUERY and it took FOREVER! And I don't know why the OPENQUERY took FOREVER but if I run the same
    query directly against Oracle it runs very quickly...like 20 seconds.
    So now I'm wondering...can I build a dataset in my SSRS Report that uses an Oracle Data source and an Oracle Stored Procedure in its Dataset that I'll create to aggregate this subset of data and then utilize its result set back in my main reporting
    Dataset that will utilize SQL Server? And how can I do that? Can I make my main Dataset reference, say, a #TemporaryTable that is created from my Oracle Dataset in its
    I'll continue to Google a few things as I await your review and hopefully a reply.
    Thanks in advance for your help.

    Hi ITBobbyP,
    According to your description you want to use data from a Oracle data source into a DataSet which retrieving data from SQL Server. Right?
    In Reporting Services, we can have multiple data sources in one project pointing to different database. And we can use separated dataset to retrieve data from different data source. However, it's not supported to combine the two datasets together
    directly. We can only use Lookup(), LookupSet() function to combine fields from different dataset into one tablix when there are common columns between two datasets. This is the only way to make tow result sets together in SSRS.
    Reference:
    Lookup Function (Report Builder and SSRS)
    LookupSet Function (Report Builder and SSRS)
    Best Regards, 
    Simon Hou
    TechNet Community Support

  • How to split query results

    Does anyone if there is a method to split up results of a query based on a specific number to stop and split at?
    For example, I want to pull out all of these numbers from my database....say 1 - 20. I want to show them on the page in order, but I would want to stop once I hit a preset number, say 12.5, then continue on.  So I would need a way to show this:
    My Numbers:
    1,2,3,4,5,6,7,8,9,10,11,12,.5
    Total equalling 12.5
    Numbers after split:
    .5,14,15,16,17,18,19,20
    Total above 12.5
    I'm basically adding numbers in my database, but need to cut it off at a certain predetermined point (in this example 12.5) and start the rest after that point.
    Right now I'm using coding that tries to split the results from a users input and insert them into the database. I'm running into problems displaying that data correctly though. It seems it would make more sense to just input everything normally, then display everything and spit it there.
    Any help in the right direction would be greatly appreciated. I'm stumped on this!

    Hmmm, I'm doing some research on the Query of Queries, I'm not sure if that will work. I'm wondering how that method would know to split an entry in the db. Because if I wanted to stop at 12.5 it would actually have to split 13 in half and give .5 to the first section and .5 to the second section.

  • Exporting query result set into CSV file using Forms

    Hi ,
    My requirement is
    -> I need to create a form where I have a Multi line text box and two button.
    -> When I enter a query in text box and click on Execute button, It should execute a select query.
    -> After execution, Result set needs to be exported into an Excel file.
    Please give a hint how to do this????
    Thanks,
    maddy

    as you are using text item to write SQL query by the user
    so for that you need to use the exec_sql package to parse the text items query and get definitions and values of the columns being
    resulted in the result set of the query.
    once your query is execute to the desired connection then you need to use fetch the result to the CSV file by use of the TEXT_io package
    which will open the text file with .csv extension and you have to pass the each line to that text file with comma separated values as "ss","rr" etc.
    or you can use the ole2 package to call the excel application and then fetch the data of exe_sql query to that.

Maybe you are looking for