Help summarizing a series of numbers

Hello,
The following SQL gives the output as
450039 - 450090
450041 - 450041
WITH wsh_Serial_numbers as
( select
72016 delivery_detail_id , 450039 fm_serial_number, 450039 to_serial_number from dual
union all
select 72016 ,450040, 450040 from dual union all
select 72016, 450041, 450041 from dual union all
select 72016, 450089 ,450089 from dual union all
select 72016 ,450090 ,450090 from dual )
SELECT from_num||' - '||to_num Serial_Numbers
FROM
WITH all_data1 AS
SELECT delivery_detail_id detail_id,
fm_serial_number f_serial_no ,
to_serial_number t_serial_no ,
NVL(lead(fm_serial_number) over (partition BY delivery_detail_id order by fm_serial_number)-fm_serial_number,1) lead
--NVL(fm_serial_number-lead(fm_serial_number) over (partition BY delivery_detail_id order by fm_serial_number),1) lead
FROM wsh_Serial_numbers all_data1
WHERE delivery_detail_id = 72016--p_delivery_detail_id
ORDER BY delivery_detail_id
SELECT detail_id ,
MIN(f_serial_no) FROM_num,
MAX(f_serial_no) TO_NUM
FROM all_data1
GROUP BY detail_id, lead
ORDER BY MIN(f_serial_no)
But the desired result is
450039 - 450041
450089 - 450090
Could some one suggest how do I get this result?
Regards,
Srini

Hi,
Solution with model caluse( 10g).
Regards salim.
select delivery_detail_id , min(fm_serial_number)||'-'|| max(to_serial_number)  res
from (
        select delivery_detail_id ,  fm_serial_number,  to_serial_number,grp
        from wsh_Serial_numbers
        model
        partition by (delivery_detail_id)
        dimension by( row_number()over(partition by delivery_detail_id order by fm_serial_number) rn)
        measures(fm_serial_number,  to_serial_number, 0 grp)ignore nav
        ( grp[any]= case when nvl(fm_serial_number[cv()]-to_serial_number[cv()-1],1)=1  then
        grp[cv()-1] else grp[cv()-1]+1 end )
group by delivery_detail_id ,grp
WITH wsh_Serial_numbers as
( select 72016 delivery_detail_id , 450039 fm_serial_number, 450039 to_serial_number from dual union all
select 72016 ,450040, 450040 from dual union all
select 72016, 450041, 450041 from dual union all
select 72016, 450089 ,450089 from dual union all
select 72016 ,450090 ,450090 from dual )
select delivery_detail_id , min(fm_serial_number)||'-'|| max(to_serial_number)  res
from (
        select delivery_detail_id ,  fm_serial_number,  to_serial_number,grp
        from wsh_Serial_numbers
        model
        partition by (delivery_detail_id)
        dimension by( row_number()over(partition by delivery_detail_id order by fm_serial_number) rn)
        measures(fm_serial_number,  to_serial_number, 0 grp)ignore nav
        ( grp[any]= case when nvl(fm_serial_number[cv()]-to_serial_number[cv()-1],1)=1  then
        grp[cv()-1] else grp[cv()-1]+1 end )
group by delivery_detail_id ,grp
DELIVERY_DETAIL_ID RES                                                                             
             72016 450039-450041                                                                   
             72016 450089-450090                                                                   
2 rows selected.

Similar Messages

  • Contraction of series of numbers

    I'm sure I've seen this script somewhere in the forums, but I haven't managed to find it regardless of the search terms I use.
    Basically I'm trying to contract a series of numbers into a span of numbers.
    For example:
         41, 42, 43, 44, 45
    will become:
         41-45
    After that I will write a script to further reduce that to '41-5' as suitable for indexes.
    Of course, this is more of a pure javascript problem than a pure InDesign problem since we are just dealing with a string, then converting to an array of numbers, then contraction. But I'm sure I found it here... anyway.
    Any help with finding this script/thread is much appreciated.

    Thank you for your prompt attention to my problem. The result should be an array of strings, rather than a number. As such, this is far from solved.
    Anyone able to address the original problem of contracting spans of numbers?
    I'm sure we've dealt with this before. My search terms are wanton.
    In more detail: when finished with index generation in InDesign we often end up with a series of sequential numbers. The pure way to deal with this is to modify the index entires to deal with the relevant spans (via styles, page count, etc), but without the time (or client budget) I'm looking for a way to reduce a series of numbers into an array of number spans.
    (Yes, I realise we are converting strings to numbers and then re-combining as strings, but I'm sure we've dealt with this before. Brain's trust, haven't we done this before?)

  • How do I go about getting the product serial number to register my product as well as install my product.  I bought it with a product box.  On the software disc sleeve, there is a series of numbers pasted at the bottom of the sleeves but this is not valid

    How do I go about getting the product serial number to register my product as well as install my product.  I bought it with a product box.  On the software disc sleeve, there is a series of numbers pasted at the bottom of the sleeves but this is not valid.  When I tried to type this in for registration, it does register as this numbers also contain letters in it.  Apparently the registration boxes accept numbers only.  What do I do with a useless product for which I have paid good money for it?????

    This is the simple solution which was offered to me when I tried to get the serial code on line.
    The box and disc sleeve do not contain a series with 24 numbers which I presume is the product code to install.
    I tried to redeem the registration code by following what they recommended, but inevitably it gets to the page that showed the registration boxes that need 24 serial numbers and I got stuck again.
    This product is so different what my previous experiences of other software products where I just enter the serial number straight from the disc sleeve and then I got registered and go on to use the software.
    I is really frustrating, spending the last two hours trying to get my product going....

  • How to create a monthly series in numbers

    I'm trying to create a monthly date series in numbers for iphone app. When I try to fill down A1:A2, it is presented as B1:B5. I want the column to show the  first day of each month. I can't find a function that accomplishes this.
    Header 1
    Header 2
    6/1/13
    6/1/13
    7/1/13
    7/1/13
    7/31/13
    8/30/13
    9/29/13

    Hi DC,
    You've asked in the community discussing Numbers for Mac OS X, so this response may not be applicable to Numbers for iOS. If not, you migth try reposting your question in the iWork for iOS community.
    Here are two methods using formulas to ceate the date series you want:
    Column B: Seed date is entered in B2.
    Formula is entered in B3 and filled down to end of column.
    B3: =EOMONTH(B2,0)+1
    Column C: Formula entered in C2 and filled down.
    C2: =DATE(2013,ROW()-1,1)
    Note the warning triangles in the last three rows. These warn that the formula is receiving a number greater than 12 for the month argument to the DATE formula. It is a warning of an unusual situation, but not a red error alert as the formula continues to produce the cirrect result.
    Italics formatting was applied manually to draw attention to these three cells. The blue triangle may be dismissed with two clicks, one to show the warning:
    the other to tell Numbers to ignore the cause. This must be repeated for each cell showing this error.
    Regards,
    Barry

  • IN NUMBERS HOW DO YOU FILL IN FOR A SERIES OF NUMBERS OR DATES

    In numbers how do you fill in for a series of numbers or dates without doing it manually

    You can enter a value in two cells that establishes a pattern, then select the two cells, then click (and hold) on the little circle at the bottom right corner of the selection and drag to fill as needed.
    A Number sequence:
    A Date sequence:

  • I am trying to copy and paste a series of numbers from numbers to pages but I keep getting a red triangle indicating formula error. Is there a way a way to open pasting options to copy just the value to avoid writing every single number??! Thanks..

    I am trying to copy and paste a series of numbers that were calculated in a numbers spreadsheet to a document on pages but I keep getting a red triangle indicating a formula error. Is there a way to open pasting options to copy just the value to avoid writing every single number??! Thanks..

    Hi Jess'D,
    Have you tried Menu>Edit>Paste Formula Results?
    quinn

  • Javascript error on - Help - Learn how to use Numbers with this online...

    I am trying to find out more about Numbers. I am using iTunes 9.1.1 on a Vista PC. I get a Javascript error in Internet Explorer 8 when I try to access:
    Help - Learn how to use Numbers with this online resource.
    http://help.apple.com/numbers/1.0
    The link redirects to the following page:
    http://help.apple.com/iwork/safari/interface/#tan727163ed
    The above page is blank except for boxes for Keynote Help, Pages Help, Numbers help, and a blank input field that seems to do nothing. Here is the Javascript error message from Internet Explorer 8:
    Webpage error details
    User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.5.30729; .NET CLR 3.0.30729)
    Timestamp: Tue, 1 Jun 2010 20:55:54 UTC
    Message: This command is not supported.
    Line: 1
    Char: 41589
    Code: 0
    URI: http://help.apple.com/iwork/safari/interface/javascript.js

    Link also does not work for me in WIN 7 with IE8. However, it does work in Chrome in WIN 7. It also works in Safari on my G4. Suggest you try Chrome or it may work in another browser like FireFox or Safari in Vista.

  • Please Help in generation of Random Numbers & Characters

    hai friends,
    Please help me to generate random Numbers and Characters to the Fields of the Table.
    Please Send code to it.
    madhava

    It's easier enough. Just use the DBMS_RANDOM package supplied by Oracle.
    SQL> desc rndm
    Name                                      Null?    Type
    COL1                                               NUMBER
    COL2                                               VARCHAR2(10)
    COL3                                               DATE
    SQL> BEGIN
      2     DBMS_RANDOM.initialize(12348765);
      3     FOR i IN 1..4 LOOP
      4        INSERT INTO rndm VALUES (dbms_random.value
      5                                 , dbms_random.string('A', 10)
      6                                 , sysdate + dbms_random.value(1,1000));
      7     END LOOP;
      8  END;
      9  /
    PL/SQL procedure successfully completed.
    SQL> SELECT * FROM rndm;
          COL1 COL2       COL3
    .028766128 pUFMxywBzC 14-JAN-07
      .7524715 SupFLVZmEC 22-JUN-07
    .454116997 EHCEZKPORm 14-FEB-05
    .330733477 gycpybxdRS 12-MAR-07
    SQL> Note that the published API seems to have changed in 9.2 (if not earlier), with the apparent sole purpose of DBMS_RANDOM being the generation of random numbers. However, as you can see, the old methods still work. Not sure what Oracle are up to.
    Cheers, APC

  • Lack of series/episode numbering on guide?

    Can anyone explain why there is not any episode/series numbering on the program listing? I find this very frustrating when there are multiple copies of a program recorded or when I want to record a program.
    Regards
    corpx

    guilbo wrote:
    ikolpdog wrote:
    Masona is right:
    TVGuide
    Recordings
    Scheduled Recordings
    Select your chosen Program
    Series Info
    Change Settings
    Show Type -  Change to First run only
    Save
    Pain in the Arris but it does work.
    HA HA HA. You just tell the best jokes. Try that with just about anything on BBC3 or ITV2 and see how far you get.
    Why Guilbo, I didn't think you were capable.
    Of having a go at another user.
    You have been so helpful in so many circumstances, to so many users, I'm shocked.
    I do it all the time, to trolls, but hey, thats me. But I've never seen you do it, to anyone. On this, or any other forum.
    It's a surprise to say the least.
    Are you OK?
    I guess there's a first for everything...
    Rank - Mostly Harmless.

  • Help with iPad Identifying Phone Numbers in iMessage Send & Receive Settings / iMessage Syncing Help - iOS 6 - iPhone - iPad

    With iOS6, iPhone and iPad users will see that their Send & Receive iMessage settings have updated across their devices to be made available at both phone numbers and email addresses. You may have also seen alerts on one or more of your devices advising that another device is now using the same Apple ID/phone number for iMessage.
    Being able to be reached on iMessage on both Apple ID and phone numbers across devices means that iMessage can keep the same thread and sync across devices.
    Due to having 2 iPhones on different phone numbers running along side my iPad at one time, (whilst I was waiting for my phone number to be moved to a new provider), my iMessage settings on my iPad lost my phone number completely. I thought I would document the steps to recover this for anyone in the same boat.
    1. Check that you are signed in with the same iCloud Account on both iPad and iPhone.
    2. Turn off iMessage on your iPad from Settings > Messages.
    3. On your iPhone, go to Settings > Messages > Send & Receive. You should see your phone number and your iCloud email address in the 'Your can be reached by iMessage at:' list. Make sure both are ticked.
    4. At this point, I synced my iPhone with iTunes, then synced my iPad with iTunes.
    5. On your iPad, turn iMessage back on - your phone number should now show in the 'You can be reached by iMessage at:' list. Tick the phone number. You should receive an alert on your iPhone.
    This should resolve the issue.
    With the above set up and with the iOS 6 updates, iMessage should now sync fine across devices however I have still found the most successful way to run iMessage is to always start new conversations from your Apple ID and to start new threads by addressing the first message to an Apple ID from an Apple ID.
    To do this, go to Settings > iMessage > Send & Receive and tick your Apple ID in the 'Start new conversations from:' list, then start a new iMessage thread to the recipients Apple ID. This way, the thread will sync across iPad and iPhone. Note that a thread set up this way will not fall back on SMS, so you get a clean iMessage thread. This method also worked/works on iOS 5, as long as you send the first message of a new thread from an iPad (which can only send via Apple ID) to an Apple ID.
    Hopefully this helped someone!

    ipad has no phone number, you use a same email address for both devices. and set it in Settings>Messages>Send & Receive

  • HELP with Satellite Series - P305-S8837; displaying blank screen with cursor

    Help! I have a the P305-S8837 laptop in the Toshiba Satellite Series. I have had the laptop for several months now and it's been working fine until now. I was using it this morning (on the internet) and it started freezing up and so I hit Crtl + Alt + delete and selected the option to restart. It restarted and asked which mode I wanted to start it up in (safe mode, safe mode w/networking, etc.) and I selected the normal option. It started out fine - little windows logo came on with the sound and then went into the Welcome Windows Home Vista premium page (that's like bluish greenish) and then afterwards the screen just goes blank with the exception of the mouse cursor. I let it sit for about an hour and there was no change. I have tried pressing the Crtl + Alt + delete and that has had NO affect. So i manually turned it off and then back on using the power button and tried starting it up in Safe mode w/networking and then just safe mode - both are able to get to the welcome screen but after that it's just a blank screen with cursor and it says safe mode and stuff on the border. Crtl + Alt + delete does not work in the safe mode w/networking but in just the regular safe mode it will go to that same screen that is the welcome and ask if I want to lock the computer, change users, start task manager or restart / shut down. I have selected the restart option and nothing happens and then the Crtl + Alt + delete option no longer works. I have tried manually starting the laptop with the battery unattached and just using the AC Adapter and that has had no impact. I have tried just using the laptop's battery only with no AC Adapter and that has had no impact.
    As you can see, I am in desperate need of some assistance! Please tell me what to do!
    Thanks

    Satellite P305-S8837 
    Turn the computer on and immediately press and hold the F8 key.
    On the Advanced Boot Options menu, choose Repair Your Computer.
    When you reach the System Recovery Options menu, choose Startup Repair.
    If that doesn't do the trick, go back to the System Recovery Options menu and do a System Restore.
    If that doesn't fix things either, go back to the System Recovery Options menu, choose Command Prompt, and follow the directions here
    How to use the Bootrec.exe tool in the Windows Recovery Environment to troubleshoot and repair start...
    Good luck!
    -Jerry

  • Pages 5.1 can anyone help with removing previous page numbers please?

    Hi.  in the new pages 5.1  I have made a section break at page 10 in a document and found how to start numbering from page 10 as page 1. Can anyone please tell me how to remove the page numbers from 1 to 10 that preceed this section?

    from the speed can I assume that it was adsl (copper) and not fibre connection?
    which hub do you have?
    can you enter your phone number and post results remember to delete number  https://www.btwholesale.com/includes/adsl/main.html
    If you like a post, or want to say thanks for a helpful answer, please click on the Ratings star on the left-hand side of the post.
    If someone answers your question correctly please let other members know by clicking on ’Mark as Accepted Solution’.

  • Please Help! My Pages, Keynote & Numbers won't open

    Updated Keynote (6.2.2) , Pages (5.2.2) & Numbers (3.2.2) August 25th
    Updated to Mavericks 10.9.4 September 10th.
    K, P & N would not open before or after system upgrade. When I open the app, it takes me to my Documents folder. I can't even download them again because they say installed. If I deleted them, can I re-add K, P & N for free? They came with my computer.

    Hey Jen127,
    Thanks for the question. When you open Pages, Keynote or Numbers, an “Open” dialog appears. This dialog allows you to choose to open a document (defaults to showing your Documents folder) or open a file from iCloud. In the bottom left corner there is also a “New Document” button:
    Create or open a document - Pages Help for Mac
    http://help.apple.com/pages/mac/5.0/#/tancdeedb11c
    Thanks,
    Matt M.

  • I want help doing simple programing on numbers.

    I am too lazy to try to learn it on my own. My first project would be to take the simple employee schedule template under Business in Numbers and modify it to add some sales projections. Very simple stuff.  Is there a company tha

    Under Numbers there is a template under Business that is labled Employee Schedule.
    1.  Overall the schedule is pretty good but the time for clocking in an employee only goes to 11. We are a restaurant/brewery we need clock in times as late at 9 PM and clock outs as late as 3 AM. Need that expanded.
    2.  I would like that spreadsheet to flood another spreadsheet immediately below the schedule that takes total gross salaries for each day. Start with Sunday thru Saturday. So whichever employee works on Sun gets added to the Sunday total. It would look like this, first column has the days of the week ie sun, mon, tues etc next column shows the expected total salaries for the day from the Employee Schedule.
    3. Next column would have projected sales. This number would be filled in by the supervisor and he would guess sales volume for the day.
    4.  The next column would be the result of dividing total gross salaries for each day by the sales projection made by the supervisor. Top of the column would read salaries/sales.
    5.  There would also be a total for the week with salaries/sales as some days like Monday we will be over budget and on busy days like Friday, we would be under budget. As long as my supervisors balance to 20% I will be ok, at least for now:)
    This Tool would help the supervisor to be able to set up and change sheduled hours either up or down to meet our goal of salaries not to exceed 20% of projected sales.
    I can tell this is probably simple for someone that knows this stuff, but for me, hours of time and then never getting it right would be what would happen.
    Thanks so much for your suggestion and I hope you or someone takes this on.
    Ken Carson
    Nexus Brewery
    Albuquerque, NM
    Even as I write it,

  • Formula Experts Please Help! - Extracting text in numbers

    This may be very simple, but I have cells with a variety of text in it. I want to test the text to see if it contains a value, and if it does return one value, if not another.
    eg. cell contains text "01239 Personal drawings account 89"
    Is there a way in one formula to check if the text contains "personal" and return a value if it true or false?
    My formula: =IF((SEARCH("PERSONAL", T(cell ref)))>0, "YES", "NO")
    This only works if the text contains 'personal' otherwise it returns an error.
    I'd like to nest it into one formula if possible, but I'm not sure the easiest way.
    Many thanks.
    Paul

    Paul,
    Great, glad I could help. Sorry if it didn't completely satisfy. Here's a more refined version which I didn't offer on the first serving because it somewhat clouds the primary function. You may find that you would prefer that testing blank cells gives a blank result rather than a "No" result. The formula for that simply requires that you wrap the first formula in an ISBLANK test as follows: =IF(ISBLANK(B2), "", IF(ISERROR(SEARCH("PERSONAL", T(CellRef))), "No", "Yes"))
    Happy Numbers-ing,
    Jerry

Maybe you are looking for

  • ActiveX problem in windows 7 64 bit version...

    I have x64 bit windows 7 version operating system i used my all report as printmode="Activex" 1. http://i41.tinypic.com/k9861g.png Check this URL. I just want to know after installed the printconrol.dll, how the printcontrol.dll get registered / also

  • Seems like non retina macbook pro is more expensive than retina macbook pro!

    MacBook Pro 15-inch 2.6 GHz is $2,299.00 with the Antiglare Widescreen Display now. If I wanna upgrade it with Crucial 16GB kit ($80) and 256GB Crucial m4 2.5" SSD with Data Transfer Kit ($220) it's gonna coast $2,599.00 all together.  On the other h

  • Hanging on MSN Homepage

    When I sign out of Hotmail.com and the page redirects to MSN homepage... and Firefox hangs. I must go to Task Manager and close there and restart. Have been running with no problem since new. Run virus, malware programs...nothing. No new downloads, o

  • /Contents entry in digital signatures

    Hi All, I have problem in making /Contents entry while trying to sign a PDF document.  Infact there is problem in Calculating ByteRange digest and then encrypting it. I have seen cryptographic message syntax v1.5. So I am using Signed-Data content ty

  • How do I view connection status of attendees in version 9

    I have tried Pod options but there is no option to view connection status as described in this article:http://www.connectusers.com/tutorials/2009/03/voip_best_practices/index.php