Find RANGE of Data

Hi,
I have data for which i need to prepare range script.
Sample data is
col1
1
11
2
3
B
C
B12
c1
C123
c2
c3
I need to prepare a script to dispaly the data in the following manner
val('1','3'); -- since 1,2,3 are in range so 1 to 3
val('11'); -- since 11 is not in range of any column
val('B','C'); -- since B,C are in range so B to C
val('B12'); -- since B12 is not in any range
val('c1','c3');
val('C123');
where val , ( , ) are strings which can be concatenated to the data.
I tried converting to ascii and sort it but it doesnt help since some has same starting characters.
Quick help is appreciated. Also let me know if it can be acheivable.
Thanks
Edited by: user5355175 on 6/10/2009 21:32

like this?
SQL>WITH t AS (
  2          SELECT '1' AS x FROM DUAL UNION ALL
  3          SELECT '11' FROM DUAL UNION ALL
  4          SELECT '2' FROM DUAL UNION ALL
  5          SELECT '3' FROM DUAL UNION ALL
  6          SELECT 'B' FROM DUAL UNION ALL
  7          SELECT 'C' FROM DUAL UNION ALL
  8          SELECT 'B12' FROM DUAL UNION ALL
  9          SELECT 'c1' FROM DUAL UNION ALL
10          SELECT 'C123' FROM DUAL UNION ALL
11          SELECT 'c2' FROM DUAL UNION ALL
12          SELECT 'c3' FROM DUAL UNION ALL
13          SELECT 'E06TWOWAY SPARES' FROM DUAL UNION ALL
14          SELECT 'E06Twoway Handheld Repairs' FROM DUAL UNION ALL
15          SELECT 'E06Twoway Repairs' FROM DUAL UNION ALL
16          SELECT 'TYRELAB06' FROM DUAL UNION ALL
17          SELECT 'e0528' FROM DUAL UNION ALL
18          SELECT 'e05xbr1e' FROM DUAL UNION ALL
19          SELECT 'j36647' FROM DUAL UNION ALL
20          SELECT 'j48471' FROM DUAL UNION ALL
21          SELECT 'E05CP1A04' FROM DUAL UNION ALL
22          SELECT 'j55640' FROM DUAL UNION ALL
23          SELECT 'm0810' FROM DUAL UNION ALL
24          SELECT 'm2187' FROM DUAL UNION ALL
25          SELECT 'm2210' FROM DUAL UNION ALL
26          SELECT 'nnnswork29-6-05' FROM DUAL UNION ALL
27          SELECT 'J40088' FROM DUAL UNION ALL
28          SELECT 'LPGAS-FY06' FROM DUAL UNION ALL
29          SELECT '301POT' FROM DUAL UNION ALL
30          SELECT '301RSL' FROM DUAL UNION ALL
31          SELECT '302 DRAGLINE' FROM DUAL)
32  SELECT 'val(''' || min_val || DECODE(max_val, min_val, NULL, ''', ''' || max_val) || ''')'  AS val
33    FROM (SELECT   alpha || TO_CHAR(MIN(num)) AS min_val, alpha || TO_CHAR(MAX(num)) AS max_val
34              FROM (SELECT alpha, num,
35                           SUM(DECODE(num, lag_num + 1, 0, 1)) OVER(PARTITION BY alpha ORDER BY num) AS part_no
36                      FROM (SELECT x, alpha, num, LAG(num) OVER(PARTITION BY alpha ORDER BY num) AS lag_num
37                              FROM (SELECT x, TRIM(TRANSLATE(x, '0123456789', ' ')) AS alpha,
38                                           TO_NUMBER(TRIM(TRANSLATE(LOWER(x), 'abcdefghijklmnopqrstuvwxyz', ' '))) AS num
39                                      FROM t
40                                     WHERE RTRIM(TRANSLATE(TRIM(TRANSLATE(LOWER(x), 'abcdefghijklmnopqrstuvwxyz', ' ')),
41                                                           '123456789',
42                                                           '0'), '0') IS NULL)))
43             WHERE num IS NOT NULL
44          GROUP BY alpha, part_no
45          UNION ALL
46          SELECT   MIN(x), MAX(x)
47              FROM (SELECT x, SUM(DECODE(lag_x, CHR(ASCII(x) - 1), 0, 1)) OVER(ORDER BY x) AS part_no
48                      FROM (SELECT x, LAG(x) OVER(ORDER BY x) AS lag_x
49                              FROM t
50                             WHERE x = TRIM(TRANSLATE(x, '0123456789', ' '))
51                                OR RTRIM(TRANSLATE(TRIM(TRANSLATE(LOWER(x), 'abcdefghijklmnopqrstuvwxyz', ' ')),
52                                                   '123456789',
53                                                   '0'),
54                                         '0') IS NULL))
55          GROUP BY part_no);
VAL
val('1', '3')
val('11')
val('B12')
val('C123')
val('J40088')
val('c1', 'c3')
val('e528')
val('j36647')
val('j48471')
val('j55640')
val('m810')
val('m2187')
val('m2210')
val('POT301')
val('RSL301')
val('e xbre51')
val('TYRELAB6')
val('DRAGLINE302')
val('E TWOWAY SPARES6')
val('E Twoway Repairs6')
val('E Twoway Handheld Repairs6')
val('1')
val('11')
val('2', '3')
val('301POT')
val('301RSL')
val('302 DRAGLINE')
val('B')
val('B12')
val('C')
val('C123')
val('E06TWOWAY SPARES')
val('E06Twoway Handheld Repairs')
val('E06Twoway Repairs')
val('J40088')
val('TYRELAB06')
val('c1')
val('c2')
val('c3')
val('e0528')
val('e05xbr1e')
val('j36647')
val('j48471')
val('j55640')
val('m0810')
val('m2187')
val('m2210')

Similar Messages

  • How to find a specific day in a range of dates

    Hi !
    Can someone help me with this
    I would like to find if there is a Saturday in a range of dates:
    ex: OpenDate:2012-01-19 to CurrentDate,  should return  2012-01-21
          OpenDate 2012-01-23 to CurrentDate, should return null field
    Thank you

    Hi Diane,
    You can use this formula to find a Saturday in a date range:
    numbervar days := datediff("d",{Date_Field}, currentdate)+1;
    numbervar x;
    datevar array dates;
    redim dates[days];
    datevar sat;
    for x := 1 to days do
        dates[x] := {Date_Field}+(x-1);
        if weekday(dates[x]) = 7 then
        datevar sat := dates[x];
    sat;
    Hope this helps!
    -Abhilash

  • Find operation with range of dates in entity services

    Hello,
    I created an entity service called A with 3 attributes: description (string), startDate (date) and endDate (date). I need to have a find operation that retrieves all A instances where startDate and endDate are in specific ranges of date.
    For example, operation needs to return all instances where startDate is between 01/03/2007 and 05/03/2007 and/or my endDate is between 10/03/2007 and 15/03/2007.
    Is it possible to do using entity services operations ? If yes, how can I do that ?
    Thanks in advance,

    Hi Helder,
    Create a findBy method (findbyDateRange) for the entity service with the fromDate and toDate as input parameters. In the app service create a method with four input parameters of type caf.core.timestamp/date (fromdateStart, fromdateEnd and todateStart and todateEnd). In the method implementation write :
    //instantiate query filters
    QueryFilter qfInputfromDate = new QueryFilter(fromdateStart, fromdateEnd);
    QueryFilter qfInputtoDate = new QueryFilter(todateStart, todateEnd);
    //get entity service instance
    myEntityServiceLocal entityServiceInstance = this.getmyEntityService();
    //call entity service method
    List dataList = entityServiceInstance.findbyDateRange(qfInputfromDate, qfInputtoDate);
    for(int i=0; i<dataList.size();i++)
       myEntityService data = (myEntityService) dataList.get(i);
      //do your custom processing
    retValue = dataList;
    Hope this helps.
    Thanks,
    Dipankar

  • Looking for a query to find first/last dates in overlapping dates...

    Hi,
    I'm looking for a query to find the first dates and last dates in a table conaining overlapping dates.
    I have a subscription table which has for each Customer start and end date for different subscriptions.
    I want to know the different ranges of date where there is subscriptions active.
    so if the table has this:
    CustID, Start date, end date
    1, 2008-01-01, 2012-06-06
    1 ,2009-01-01, 2011-01-01
    1, 2011-01-01, 2013-02-02
    1, 2013-01-01, 2013-08-08
    1, 2014-01-01, 2014-04-04
    I want to produce this result:
    custid, range start, range end
    1, 2008-01-01, 2013-08-08
    1, 2014-01-01, 2014-04-04
    the first row is the range identified from the 4 rows in my subscription table.
    thanks :)

    I think I found it...
    http://stackoverflow.com/questions/5213484/eliminate-and-reduce-overlapping-date-ranges
    let me try this method
    Hi,
    m writing to follow up with you on this post. Thanks for you posting a reply to share your workground. Was the problem resolved after performing the above link? If you are satisfied with the above solution, I’d like to mark this issue as "Answered".
    Please also feel free to unmark the issue, with any new findings or concerns you may have.
    Thanks,
    Sofiya Li
    If you have any feedback on our support, please click here.
    Sofiya Li
    TechNet Community Support

  • Limit a range of date in a prompt filter

    Hi,
    I'm trying to built a prompt filter which permit my users to prompt a range of date (ex starting date - ending date).
    But I would like to limit the range to a maximum of 50 days (from the starting date to the ending date)
    Is it possibile to do it (in WI or BO 6.5 Designer) and how?
    Thank you in advance
    Riccardo

    Hi Riccardo,
    There is an easy way to do that in universes.
    You have to create an firstobject based on your date:
    mytable.mydate
    Then create a secondobject with the same definition and a where clause like this:
    mytable.mydate BETWEEN  @Prompt('1-Start Date','D','MyClass\MyObject',mono,constrained) AND   @Prompt('2-End Date','D','MyClass\MyObject',mono,constrained)
    The List of Values used in the prompt is based on the first objects you created.
    Last, edit the list of values of the second object and in the query panel editor, click on the "Options" button and change the number of rows option to limit the returned result.
    In attachment, you will find a universe based on Club database.
    See the object "Invoice Date (50 rows max)" in "Sales" class that illustrates the purpose.
    Regards,
    Didier

  • Searching AW database for range of dates in AW 6.2.4

    I can no longer use my Microsoftworks 4 on eMac since doing a clean install of OS 10.4.11. Prior to that it worked fine in Classic mode. I copied Works folder from old Mac 6500 via home network using ethernet connection to router. Setup program became corrupted when copying from Mac 6500 to eMac, so now unable to use MSWorks. Database was pure simplicity for copying individual fields to next record, searching for range of dates, and matching records with partial string using "contains" function.
    Now using AW 6.2.4 which is more powerful but not as simple to use. Is it possible to do any of those tasks in AW? If so, how?

    1) copying data into a field in a record from the corresponding field in the preceding record
    Not automatic, but no more complicated than copying the information from the first record, then command-down and command-V; command-down and command-V; command-down and command-V; etc.
    2) matching records containing partial string
    If the partial string is expected in a particular field, use the "Match Records..." dialog from the Organize menu. Looking for records containing the word, "hoopla" in the field named "event", enter the following command: FIND("oop",'event',1)
    -- Note single quotes around the fieldname, and double quotes around text to be found. -- Search multiple fields by imbedding multiple FIND statements in an OR statement.

  • Selecting a range of data from a file

    Is it possible to only display a selected range of data from a binary file? I can read in my binary files but I would like to only send data within a user defineable range to the data portal for viewing. This range may be over multiple binary files also. I can concatenate these files already but I need to select a range to insert into the data portal.
    Thanks,
    AJL

    OK AJL,
    This sounds good. It's convenient to have the start and stop time of each segment file in the name of that file. By the way, you want to check that in the DataPlugin and "Call RaiseError()" if the data file is not named that way, otherwise you will try to read DIAdem *.DAT files with your custom DataPlugin. DIAdem will try each DataPlugin that is registered with the file's extension (i.e. *.DAT) one after the other, until one of them does not give an error. So you should always check for some identifying characteristic in your data file and "Call RaiseError()" if you don't find it, in order to abort DIAdem using that DataPlugin for files it was never intended for.
    Now to your point. How do you know which series of segment files to read from? Does your VBScript ask the user to select a particular directory that contains all these segment files? I'm going to assume so. My recommendation is that your VBScript also create a time slice configuration file in that directory that contains the information about the time slice you want to read in (start and stop times). Then your DataPlugin can look for that file name in the directory passed to it-- if it finds none it will just load the file path it was passed outright, but if it does find the time slice file it will load any and all *.DAT files in that same directory which correspond to that time slice. This includes loading only parts of one or more of the existing binary files.
    It is straightforward enough to pick out the section of the binary file you want to load with the DataPlugin, once you know the time slice information inside the DataPlugin's callback. Use the File.Position property to move the file cursor to the position of the first data point in the time slice, and use the Block.BlockLength property to specify the number of values to read in each of the channels from that starting point (to exclude the values after the desired time slice). I assume that your binary data is stored interleaved and that you are using DirectAccessChannels to read the values in your DataPlugin.
    Finally, for time slices that span multiple segment files, you will need to load these to separate groups in the Data Portal with the DataPlugin. Then the VBScript can consolidate these channels into long concatenated channels in a new group and delete the temporary segmented groups. In a future version of DIAdem the DataPlugin API will have the ability to do this mapping for you, but not yet. I also have VBScripts that do this concatenation already-- you can download them from www.ni.com/support/diasupp. They're designed for concatenating channels from multiple ASCII/Excel/DAT files.
    Let me know what else you need,
    Brad Turpin
    DIAdem Product Support Engineer
    National Instruments

  • How to generate SIDs for a particular range of data for a DSO ?

    Hi All,
    Please let me know if there is any way to generate SIDs for a particular range of data for a DSO which does not have any SID values. I need this as when i am trying to load data from DSO to InfoCube it's taking a lot of time. When i tried to find the reason behind it, i came to know that most of the time is going in SID creation for the data which is getting loaded. Please share some solution for the same. Thanks...

    Hi,
    Try this.
    Create an internal table and populated it with the values present in the F4 help of the field. Then in AT SELECTION-SCREEN event check the value of the field with the values in the internal table and display the appropriate message.
    Sharin.

  • Need to create report based on criteria between a range of dates

    I am very new to Numbers '09 and a beginner with spreadsheets.  I've searched and can't find a formula that fits this.  I've tried Match/IF  Match/Index  VLookup  If/And formulas but can't get the right results.
    I need to be able to create a report based on data from Master Spreadsheet.  I need formulas that will populate Report Page B8:B17 and D8:D17 from data in Master Spreadsheet that meets criteria range of dates (Report Page B5 and B6).
    The closest I've come was an IF(AND formula, but that left blank lines on my report page.  (I understand why, just not sure how to resolve it.)
    P.S.  I am working in Numbers '09 on an iPad (yes, the samples below are not in the Numbers program, but it was easier to do screen shots on my Mac notebook
    Master Spreadsheet:
    Report Page:

    Hi KC,
    So you are trying to retrieve the dates and associated comments for a specific student in a specific class between the two dates.
    Here's an example, using OFFSET and MATCH, plus an added index column on the Master table. Formulas and discussion below.
    Column E uses IF and AND to determine which rows contain the data to be transferred, thn uses MAX to number those rows.
    Master::E2: =IF(AND(A>=Report :: $B$5,A<=Report :: $B$6,B=Report :: $B$3,C=Report :: $B$4),MAX($E$1:E1)+1,"")
    Fill down to the bottom of column E.
    I don't see a need to repeat the "Date" and "Comment" labels on each row containing a date and comment, so I've placed these as fixed text in A8 and B8 of the Report table, and filled the cells below those with the dates and comments using MATCH and OFFSET.
    A9: =IF(ROW()>MAX(Master :: $E)+8,"",OFFSET(Master :: $A$1,MATCH(ROW()-8,Master :: $E,0)-1,0))
    B9: =IF(ROW()>MAX(Master :: $E)+8,"",OFFSET(Master :: $A$1,MATCH(ROW()-8,Master :: $E,0)-1,3))
    As can be seen, these formulas are identical except for the column-offset argument in OFFSET, shown in bold in the examples.
    Fill both formulas down to the bottoms of their columns.
    Regards,
    Barry

  • I can not find (see) the Data Control Accordion

    Hello all,
    I cannot find (see) the Data Control Accordion, I just installed the Jdeveloper 11g (Oracle JDeveloper 11g (11.1.1.2.0) - November 2009) from this link http://www.oracle.com/technology/software/products/jdev/htdocs/soft11.html
    I started a new ADF BC application, but I cannot find the data control accordion to drag and drop the components I created in the application model. Is there anything I must do after installation (post installation), is there any libraries need to be installed? Please, I need a help to create my application, I’m totally stuck, many thanks for any help.
    Kind regards,
    Nabil

    Shay Shmeltzer wrote:
    Can you post an image of your screen so we can see how it looks like?
    If you delete the JDeveloper\system11.1.1.2.36.55.36 directory - does your IDE get back to the right way of displaying the data control?Hello,
    Many thanks for your reply, kindly find attached screenshots for the two installation of Jdeveloper 11g I have (release 1 & 2), it shows clearly that the “Data Control” is available for release 1, but not available for release 2, even we are talking about the same application!
    Regarding the “JDeveloper\system11.1.1.2.36.55.36”, I’m not sure if I have it (attached a list of directories installed), I was not able to find it under my installation directory, therefore I can’t answer your question, but please advise if it could be the reason, how I may have it, do you think there is something wrong with the installation? I noticed that some persons having the same problem before me, so what was wrong, and how they solve it? I appreciate any help please, many thanks.
    Regards,
    Nabil
    P.S. regarding the attached files, sorry I don't know how to attach files to my reply (you may email me at [email protected] so I can send you the screenshots through email, if you please), any help regarding that too will be appreciated.
    Directory     Location
    o.adf-faces-query-and-lov-dt.11.1.1.2.36.55.36     E:\Oracle11MW\Middleware\jdeveloper\jdev\unit-tests\system11.0.0.0.0
    o.adfdt.swingcore.11.1.1.2.36.55.36     E:\Oracle11MW\Middleware\jdeveloper\jdev\unit-tests\system11.0.0.0.0
    o.adfm.11.1.1.2.36.55.36
    o.adfm.11.1.1.2.36.55.36
    o.BC4J.11.1.1.2.36.55.36
    o.bm.11.1.1.2.36.55.36
    o.css.11.1.1.2.36.55.36
    o.diagram.javadoc.11.1.1.2.36.55.36
    o.dynamic.faces.11.1.1.2.36.55.36
    o.ide.11.1.1.2.36.55.36
    o.j2ee.11.1.1.2.36.55.36
    o.jdeveloper.11.1.1.2.36.55.36
    o.jdeveloper.esdk.11.1.1.2.36.55.36
    o.struts.11.1.1.2.36.55.36
    o.struts.adf.11.1.1.2.36.55.36
    o.xsqldt-ide.11.1.1.2.36.55.36

  • How can I find out the date of a movie I am trying to pre-order if the date is not available/showing in the "manage pre-order" section?

    How can I find out the date of a movie I am trying to pre-order if the date is not available/showing in the "manage pre-order" section?

    Thanks so much for your reply King_Penguin. No, sadly there is not indication of the expected release date on the film, it's no where to be found. I have also tried to look in other places online, but no luck. I guess your latter statement jives more with my situation, that  being the studio/rights-holder hasn't feel inclined to provide the date.

  • How do I find out the date in which I registered my imac?

    How do I find out the date in which I registered my imac?

    It doens't really matter what date you registered it. However if you are looking to see when your expiration on AppleCare is/was it is 3 years from the original date of purchase. You can use the Apple Online Service Assistant afer you input the serial number click the link that says See your service and support coverage.

  • How to load a range of data in Diadem?

    Hello; I have a set of Access DB containing analytic data of 5 jears. How can I import a range of data (eg. all year 2003 data)in Diadem for analysis?
    Thank's

    Thank's,
    but I couldn't choose explizit the time channel. Also I couldn't set a command like 'between 1.1.2003 and 31.12.2003'. Attached is an exemple of the dataset. The time channel is '50_DAT'.
    It would be nice to get an answer.
    Thank's Matthias
    Attachments:
    B0P2DAT8_50.MDB ‏400 KB

  • Need to know the sqluery to find the disabled date from OIM 9.1.0.1

    Hi Experts,
    Need very urgent inputs from you all for the preparation of our audit.
    We are using OIM9.1.0.1
    We need to know the sqlquery for finding the Disabled date in OIM given the user ids, as currently we are unable to get the exact data from Historical Reports Option in OIM.
    I need to give in this format:
    select usr_login, usr_disabled from schemaname.tablename where usr_login in
    ('aaa','bbb'..... etc)
    We have three attributes :USR_DISABLED_BY_PARENT,USR_DISABLED,USR_DEPROVISIONING_DATE,but none of them give the exact date,
    USR_DISABLED gives just a flag as 1 or 0.
    Also there are no other fields in the corresponding usr table.
    So how to fetch the exact Disabled date from OIM system when I input the user ids.
    Your immediate response is appreciated.
    Thanks
    SS

    In the entire thread many experts have given nice queries in different formats...
    The best approach would be to open up the SQL Developer, connect with the OIM Database and experiment with all sorts of SQL queries provided by all the experts..
    Learn some SQL techniques, like Inner Join etc...
    Then you yourself will be able to figure out what you need, in exactly which format, for which users and for whom you have to restrict
    Then not only this question, you would be able to solve dozens of similar such issues yourself...
    And trust me, nothing can match that...
    Just in case, you are not familiar with SQL Developer,
    http://www.oracle.com/technetwork/developer-tools/sql-developer/downloads/index.html
    Oracle SQL Developer 3.2.1 (3.2.10.09.57)
    September 24, 2012
    The Disabled DATE will be the creation date of that entry in the UPA_FIELDS table when Users.Status changed to Disabled.
    SELECT USR.USR_LOGIN, UPA_FIELDS.CREATE_DATE
    FROM UPA_FIELDS
    WHERE UPA_FIELDS.FIELD_NAME='Users.Status'
    AND UPA_FIELDS.FIELD_NEW_VALUE='Disabled'
    AND UPA_FIELDS.UPA_USR_KEY=USR.USR_KEY
    AND USR.USR_LOGIN NOT IN ('XELSYSADM', 'XELOPERATOR', 'WEBLOGIC');

  • How to find out when data was deleted from table in oracle and Who deleted that

    HI Experts,
    Help me for below query:
    how to find out when data was deleted from table in oracle and Who deleted that ?
    I did that to fidn out some data from dba_tab_modifications, but I m not sure that what timestamp shows, wether it shows for update,insert or delete time ?
    SQL> select TABLE_OWNER,TABLE_NAME,INSERTS,UPDATES,DELETES,TIMESTAMP,DROP_SEGMENTS,TRUNCATED from dba_tab_modifications where TABLE_NAME='F9001';
    TABLE_OWNER                    TABLE_NAME                        INSERTS    UPDATES    DELETES     TIMESTAMP         DROP_SEGMENTS TRU
    PRODCTL                        F9001                                                     1683         46       2171            11-12-13 18:23:39             0                   NO
    Audit is enable in my enviroment?
    customer is facing the issue and data missing in the table and I told him that yes there is a delete at 11-12-13 18:23:39 in table after seeing the DELETS column and timestamp in dba_tab_modifications, but not sure I am right or not
    SQL> show parameter audit
    NAME                                 TYPE        VALUE
    audit_file_dest                      string      /oracle/admin/pbowe/adump
    audit_sys_operations                 boolean     TRUE
    audit_syslog_level                   string
    audit_trail                          string      DB, EXTENDED
    please help
    Thanks
    Sam

    LOGMiner --> Using LogMiner to Analyze Redo Log Files
    AUDIT --> Configuring and Administering Auditing

Maybe you are looking for