Bin fitting with a counter using both analytics and model clause.

11.2.0.3
This falls under 'just want to figure out how to do it'. Its not critical for work. I want to try to see if its possible to do this with both analytic function and with a model clause. Just to see if its possible. It has been stumping me.
I got the idea to look at this from this article about bin fitting. I have been playing with the model clause and I think you would do something with the 'increment' clause, but I dont see a way to reset it to 1 at a certain point.
http://www.oracle.com/technetwork/issue-archive/2012/12-mar/o22asktom-1518271.html
The case I want to look at is, bin fitting based on a counter and a partition by. In theory this should be simpler than the example in the link.
[code]
create table myrooms (
room_number number,
person_id        number);
create unique index myrooms_ind on myrooms(room_number,person_id);
[/code]
Person_id is not unique. So row_number is more appropriate than rank or dense_rank.
Problem: Partition by room_number, assign up to 50 people to a specific group with in the same room. This seems like it could be handled with a row_number() and a window clause, but that is not supported.
I need to basically translate the old procedural counter into sql:
pseudo-code that does not compile that would have a reason to use this logic.
[code]
declare
  cursor curGetRoom
     select room_number,person_id
        from my rooms
      order by room_number;
counter number := 1;
vCurrentRoom myroom.room_number%type;
begin
    for i in curGetRoom loop
        if vCurrentRoom is null then
           vCurrentRoom := i.room_number;
        elsif vCurrentRoom = i.room_number then
              if counter < 51 then counter :=counter+1;
              else counter := 1;
        else
             vCurrentRoom := i.room_number;
            counter :=1;
        end if;
end;
[/code]
simple partition query., but I dont see a way to limit this to 50 and then start over. Window functions are not supported with row_number()
[code]
select room_number,person_id,row_number() over (partition by room_number order by person_id) rn
from myrooms
[/code]

11.2.0.3
This falls under 'just want to figure out how to do it'. Its not critical for work. I want to try to see if its possible to do this with both analytic function and with a model clause. Just to see if its possible. It has been stumping me.
I got the idea to look at this from this article about bin fitting. I have been playing with the model clause and I think you would do something with the 'increment' clause, but I dont see a way to reset it to 1 at a certain point.
http://www.oracle.com/technetwork/issue-archive/2012/12-mar/o22asktom-1518271.html
The case I want to look at is, bin fitting based on a counter and a partition by. In theory this should be simpler than the example in the link.
[code]
create table myrooms (
room_number number,
person_id        number);
create unique index myrooms_ind on myrooms(room_number,person_id);
[/code]
Person_id is not unique. So row_number is more appropriate than rank or dense_rank.
Problem: Partition by room_number, assign up to 50 people to a specific group with in the same room. This seems like it could be handled with a row_number() and a window clause, but that is not supported.
I need to basically translate the old procedural counter into sql:
pseudo-code that does not compile that would have a reason to use this logic.
[code]
declare
  cursor curGetRoom
     select room_number,person_id
        from my rooms
      order by room_number;
counter number := 1;
vCurrentRoom myroom.room_number%type;
begin
    for i in curGetRoom loop
        if vCurrentRoom is null then
           vCurrentRoom := i.room_number;
        elsif vCurrentRoom = i.room_number then
              if counter < 51 then counter :=counter+1;
              else counter := 1;
        else
             vCurrentRoom := i.room_number;
            counter :=1;
        end if;
end;
[/code]
simple partition query., but I dont see a way to limit this to 50 and then start over. Window functions are not supported with row_number()
[code]
select room_number,person_id,row_number() over (partition by room_number order by person_id) rn
from myrooms
[/code]

Similar Messages

  • Weird issues with file share using both SMB and AFP?

    I use my Xserve with 10.4 server primarily as a file server (with a huge RAID array attached via Ultra320 SCSI). I've served files from this server over SMB ("Windows" sharing) to both PCs and Macs for a few years now with no big issues. The files are being shared in a collaborative environment with extensive user accounts and ACLs set up.
    I would like to turn on AFP for these same file shares, so those accessing with a Mac can have the added benefits of AFP over SMB. However, I've heard some rumors of some complicated issues developing from the use of both AFP and SMB together on the same folders, in a mixed environment.
    The rumors I've heard are things that would happen rarely but enough for it to be significant. For example, a file created over SMB and then edited over AFP would have some problems being re-edited over SMB again, due to some complicated feature that the rumor is unable to explain (something with a resource fork or file locking?). Maybe something weird that just involves the Adobe Creative Suite?
    Anyway, I figured I'd throw this out there. Anyone who serves files over both protocols to a varied set of computers and applications having weird issues? Or is everything working for you? Thanks in advance.
    Message was edited by: dtemp

    Thanks for the responses!
    re:crop
    It's coming in as cropped with no way to fix it that I can see.
    Pressing space or opening in preview shows the full image but if it gets anywhere near Photoshop it comes in auto-cropped.
    I'm starting to this it's a bug and will be reporting it to Adobe.

  • Help with a PCR using both 401KL and 401KS

    Hi,
    Has anyone set up a supplemental savings plan that begins deductions when 401k limits hit either 401KL or 401KS?  I have it setup using 401KS and it works great but unfortunately that scenario is only for one employee out of 48.  I really need to be able to compare against both 401KS and 401KL to fully automate this.  I'm new to PCR's  so any advice would be greatly appreciated...
    Thank you,
    Stephanie

    I'm sorry.  Here is the query:
    --Declare @EMail_Address nvarchar(100) = null
    Select SVAssociationID.R_ShortValue as MATRIX_AssociationID, Matrix_Modified_DT as Matrix_LastModified
      ,RTRIM (MLS_ID) As Matrix_MLS_ID
      , ISNULL(EMail_Address, '') AS MATRIX_member_Email
      ,RTRIM (EMail_Address) as Matrix_Member_EMail
      --,RTRIM( LTRIM(  ISNULL (@EMail_Address, '') ) ) as Matrix_Member_EMail 
      ,Last_Name AS MATRIX_LastName, Nickname AS MATRIX_NickName
      FROM    dbo.Agent_Roster_VIEW a
            LEFT JOIN dbo.select_values_VIEW SV ON a.Status_SEARCH = SV.ID
            LEFT JOIN dbo.select_values_VIEW BillType ON a.Bill_Type_Code_SEARCH = BillType.ID
      LEFT JOIN dbo.select_values_VIEW SVAssociationID ON A.Primary_Association_SEARCH = SVAssociationID.ID
    WHERE   Status_SEARCH IN (66,68) 
        Order by MLS_ID
    Results:
    MATRIX_AssociationID
    Matrix_LastModified
    Matrix_MLS_ID
    MATRIX_member_Email
    Matrix_Member_EMail
    MATRIX_LastName
    MATRIX_NickName
    STC
    09/02/14
    CCWILLI
    [email protected]
    [email protected]
    Williams                      
    Christine   
    STC
    09/12/14
    CCWORSL
    [email protected]
    [email protected]
    Worsley                       
    Charlie
    STC
    09/02/14
    CCYROBIN
    NULL
    Robinson       
    ECBR
    09/02/14
    CDABLACK
    [email protected]
    [email protected]
    Black                         
    Dale        
    STC
    09/02/14
    CDABRADY
    [email protected]
    [email protected]
    Brady                         
    David       
    Thank you,

  • During setup of new Apple TV I am not able to progress past the screen that asks if I want to share usage info with Apple.  Using both wireless and hardwire setup I've answered no - then yes - but I cannot get the system to accept an answer. Anyone else?

    Aside from not being able to progress past the question of sharing info with Apple  - I've also noticed that the remote does not function when I presss the "select" button - only when I press the "menu" button can I acknowledge a question or a step in the setup proccess.  Help!

    From: Test Screen Name [email protected]
    Sent: Sunday, August 04, 2013 11:32 AM
    To: gunner0490
    Subject: I'm not able to open PDF files in Adobe Reader XI.
    Re: I'm not able to open PDF files in Adobe Reader XI.
    created by Test Screen Name <http://forums.adobe.com/people/TestScreenName>  in Adobe Reader - View the full discussion <http://forums.adobe.com/message/5565198#5565198

  • I currently use an iPhone, an iPad, and a Mac computer for business.  The three devices have Contacts Managers that sync with each other through both Google and through Mobile Me.  Currently, this has created a mess of duplicate contacts.  Please researc

    I currently use an iPhone, an iPad, and a Mac computer for business.  The three devices have Contacts Managers that sync with each other through both Google and through Mobile Me.  Currently, this has created a mess of duplicate contacts.  Please advise me on the steps necessary for removing these duplicates and establishing a syncing solution that doesn't regenerate the duplicates.  There are several applications available that remove duplicates, but I am not sure which ones work or don't work.  I want information on this, but most importantly I want to understand how to fix this problem permanently.  Also, I read somewhere that Mac's new operating system, Lion, can help deal with duplicates.  I don't have Lion, but I would be willing to get it, if this would fix the problem.

    Had the same problem with 4 devices (two computers, an iPhone and an iPod). The solution is simple: open the Address Book application in your mac, ask it to locate duplicate entries (under one of the top menu items, "edit" I think), and then ask it to consolidate them: it took me all of three seconds after I figured it out: worked like a charm! PS: if you have more than one mac with unconected Address Books, repeating the operation in the second one may be a good idea.
    Message was edited by: mfduran

  • Linking Access tables, creating a query with using both Access and Oracle

    Hello,
    I am using 3.0.04.34 version Oracle Developer. I am supposed to create a script/procedure to use both Access tables and oracle tables together. There is an option in developer to copy the access tables into oracle. But it doesn't help me. Because when we updated the access tables
    the copied ones are not be updated. How can I created a linked access tables to oracle and create a query with using both access and oracle table together.
    I will appreciate if you guys help me. I look forward to hearing from you guys.
    Thanks,
    Pinar

    Pinar,
    to be able to query MS Access tables in Oracle you need an additional product, the Oracle Database Gateway for ODBC. It allows you to link any foreign database into an Oracle database using a suitable ODBC driver. You can then access the MS Access tables through a database link based on the Database Gateway for ODBC. This will also allow you to join local Oracle and remote MS Access tables from your Oracle database.
    There's a note on My Oracle Support which gives you more details:Document 233876.1 Options for Connecting to Foreign Data Stores and Non-Oracle Databases - For example - DB2, SQL*Server, Sybase, Informix, Teradata, MySQL
    And there's also a dedicated Forum: Heterogeneous Connectivity

  • Use both iPhoto and Aperture with one library-best practice?

    I'd like to use both iPhoto and Aperture, but have both programs use/update just one photo library.  I have the latest versions of both programs, but was wondering if the optimum approach would be to:
    a)point Aperture to the existing iPhoto library and use that as the library for both programs
    or
    b)import the entire iPhoto library into a new Aperture library, delete the iPhoto library, and point iPhoto to use the Aperture library.
    I should point out that up to now I've been using iPhoto exclusively, and have close to 20K photos in the iPhoto library, tagged with Faces, organized into various albums, etc; if that makes a difference...
    Appreciate any advice!
    Thanks,
    Dave

    Thanks Frank!  I'll try it that way.
    Appreciate the help!

  • HT4818 Can you use both Bootcamp and Parallels with the same Windows 7 installed

    I have Parallels installed with Windows 7.  Can I use both Bootcamp and Parallels on the same machine depending on whether I just want to work in Windows all day (Bootcamp) or alternate during the same session (Parallels)?

    You can, yes. But there is a complication: once you activate windows it will only be activated for one of the two methods you use. So, let's say you install into boot camp and activate windows. You can then install Parallels and it will find your boot camp installation, but when running in Parallels, Windows will report that it is not activated. Or, you can activate it in Parallels and when running in Boot Camp Windows will report that it is not activated. The reason for this is because Windows thinks it is running on different computers depending on how you boot it. This may not be an issue for you if you run Windows a lot one way and just occasionally the other way, so be sure to activate Windows in whichever method you use more often. Hope this helps!

  • My apple TV is connected to a DTV with an HDMI cable and to my Yamaha receiver via optic cable. We rented a movie on Apple TV and.found that the movie played, but we only got audio for music tracks. Voice tracks were silent using both TV and receiver.

    My apple TV is connected to a DTV with an HDMI cable and to my Yamaha receiver via optic cable. We rented a movie on Apple TV and.found that the movie played, but we only got audio for music tracks. Voice tracks were silent using both TV and receiver.  This only occurred on the rented video and on recorded shows on my cable DVR. previews and other content on Apple TV are fine. Any ideas??

    Previews and trailers do not contain 5.1 audio.
    If you have recently moved your setup, you may have inadvertently changed some of the settings on your receiver. It certainly sounds as though it is unable to play the 5.1 audio from the Apple TV.

  • Can I use both Wifi and a Lan connection at the same time?

    With me back in the dorms I have been limited to a slower connection than what I would like. Now we are able to use both Wifi and a Lan line so I was wondering to somewhat "double" my speed if there was any way to use both connections at the same time.
    Now I know that you can have both plugged in at the same time, I guess what I'm asking is, is there a way that I could set programs to use one or the other? Or some kind of virtual desktop that is set to use the other connection or anything that would allow both be used at the same time.
    Or am I just wishing for something that doesn't have any possible way to work?
    -nathan
    MacBook pro 2.16 C2D 2gb ram   Mac OS X (10.4.8)  

    You can use both at the same time, but not gor Internet access if that's what you're asking.
    Now there is a thing called Link Aggregation, which combines a number of interfaces for speed/redundancy, but it really only works locally, and then only with ALL special equipment in the route, and most likely OSX Server involved.
    Sorry.

  • Can we use both INSERT and UPDATE at the same time in JDBC Receiver

    Hi All,
    I would like to know is it possible to use both INSERT and UPDATE at the same time in one interface because I have a requirement in which I have to perform both the task.
    user send the file which contains both new and old record and I need to save those in MS SQL database.
    If the record exist then use UPDATE otherwise use INSERT.
    I looked on sdn but didn't find any blog which perform both the things at the same time.
    Interface Requirement
    FILE -
    > PI -
    > JDBC(INSERT & UPDATE)
    I am thinking to use JDBC Lookup but not sure if it good to use for bulk record.
    Can somebody please suggest me something or send me the link of any blog or anything to solve this problem.
    Thanks,

    Hi ,
              If I have understood properly the scenario properly,you are not performing insert and update together. As you posted
    "If the record exist then use UPDATE otherwise use INSERT."
    Thus you are performing either an insert or an update which depends on outcome of a search if the records already exist in database or not. Obviously to search the tables you need " select * from ...  where ...." query. If your query returns some results you proceed with update since this means there are some old records already in database. If your query returns no rows  you proceed with "insert into tablename....." since there are no old records present in database.
      Now perhaps the best method to do the searching, taking a decision to insert or update, and finally insert or update operation is to be done by a stored procedure in MS SQL database.  A stored procedure is a subroutine available to applications accessing a relational database system. Here the application is PI server.   If you need further help on how to write and call stored procedure in MS SQL you can look into these links
    http://www.daniweb.com/web-development/databases/ms-sql/threads/146829
    http://www.sqlteam.com/article/stored-procedures-parameters-inserts-and-updates
    [ This part you can ignore, Since its not sure that you will face this situation
        Still you might face some problems while your scenario runs. Lets consider this scenario, after the stored procedure searches the database it found no rows. Thus you proceed with an insert operation. If your database table is being accessed by multiple applications (or users) other than yours then it is very well possible that after the search operation completed with a null result, an insert/update operation has been performed by some other application with the same primary key. Now when you are trying to insert another row with same primary key you get an error message like "duplicate entry not possible for same primary key value". Thus you need to be careful in this respect. MS SQL has a feature called "exclusive locks ". Look into these links for more details on the subject
    http://msdn.microsoft.com/en-us/library/aa213039(v=sql.80).aspx
    http://www.mssqlcity.com/Articles/Adm/SQL70Locks.htm
    http://www.faqs.org/docs/ppbook/r27479.htm
    http://msdn.microsoft.com/en-US/library/ms187373.aspx
    http://msdn.microsoft.com/en-US/library/ms173763.aspx
    http://msdn.microsoft.com/en-us/library/e7z8d5hf(v=vs.80).aspx
    http://mssqlserver.wordpress.com/2006/11/08/locks-in-sql/
    http://www.mollerus.net/tom/blog/2008/03/using_mssqls_nolock_for_faster_queries.html
        There must be other methods to avoid this problem. But the point is you need to be sure that all access to database for insert/update operations are isolated.
    regards
    Anupam

  • Since my last firefox update, I have been unable to type an email - the text box does not appear when I press 'reply' , or press 'compose'. The email provider is '123-reg.co.uk. I have been using both firefox and the provider ['webfusion Ltd/webmail123] s

    Hello. Since my last firefox update, I have been unable to type an email - the box within which one would usually type does not appear when I press 'reply' to a received email, or press 'compose'. The email provider is '123-reg.co.uk. I have been using both firefox and the provider ['webfusion Ltd/webmail123] successfully for well over a year. The provider says it is a browser problem. I can still add an attachment to the email header, which successfully can be sent, but the recipient gets my standard email 'signature' with font messages and the attachment. Can anyone help? My email addresses are [email protected] [this is the one with the issue] and [email protected] in English
    == today

    My daughter has had her Razr for about 9 months now.  About two weeks ago she picked up her phone in the morning on her way to school when she noticed two cracks, both starting at the camera lens. One goes completely to the bottom and the other goes sharply to the side. She has never dropped it and me and my husband went over it with a fine tooth comb. We looked under a magnifying glass and could no find any reason for the glass to crack. Not one ding, scratch or bang. Our daughter really takes good care of her stuff, but we still wanted to make sure before we sent it in for repairs. Well we did and we got a reply from Motorola with a picture of the cracks saying this was customer abuse and that it is not covered under warranty. Even though they did not find any physical damage to back it up. Well I e-mailed them back and told them I did a little research and found pages of people having the same problems. Well I did not hear from them until I received a notice from Fed Ex that they were sending the phone back. NOT FIXED!!! I went to look up why and guess what there is no case open any more for the phone. It has been wiped clean. I put in the RMA # it comes back not found, I put in the ID #, the SN# and all comes back not found. Yet a day earlier all the info was there. I know there is a lot more people like me and all of you, but they just don't want to be bothered so they pay to have it fix, just to have it do it again. Unless they have found the problem and only fixing it on a customer pay only set up. I am furious and will not be recommending this phone to anyone. And to think I was considering this phone for my next up grade! NOT!!!!

  • HP Laserjet Pro 400 Printer unable to print docs using both letter and legal paper

    HELP!!  Have been using an HP Laserjet Pro 400 M425dn dual tray printer for 2 years, along with a Dell laptop.  Always had ability to send documents to print using both letter and legal size paper.  Under print set-up on laptop, the option checked was always set to "Choose Paper Source by PDF Paper Size".  Now I've just purchased an HP Envy All-in-One Desktop, which does not offer that option under Print Set-Up.  While it allows for 'Auto Selection' of paper size, you are required to choose either letter or legal size paper.  I've called tech support 3 times, the latest call earlier this am, only to be disconnected.  Yesterday I was told that I should go on hp/support and update drivers.  My husband downloaded drivers, but still no fix.  Unless this issue is resolved asap, I will have no option but to return this Envy Desktop, as I cannot run my business without this option.
    Anyone have a similar problem?  How was it resolved?

    The available options will (probably) be determined by the printer driver in use.
    This , in turn, will be determined partly by which Operating System and version you are using.
    Once a printer model has been out in the field for some time (generally when the next generation (or two?) of devices has been announced to supersede it) that model becomes a 'legacy' device, and 'full-specification' printer drivers may no longer be supplied by the printer manufacturer, but basic (i.e. without too many options) drivers will (probably) instead be supplied with the operating system.

  • I'm new to Mac and the program/all called Numbers. I'm trying to use both Average and small in the same formula. What's I'm trying to do is take 20 cells, find the 10 lowest numbers, then get the average and after that multiply it by .96

    I'm new to Mac and the program/all called Numbers. I'm trying to use both Average and small in the same formula. What's I'm trying to do is take 20 cells in a column,  find the 10 lowest numbers, then get the average and after that multiply it by .96  I used to use Excel and the formula worked fine in that. Here is my Formula
    =(average(small(H201:H220,{1,2,3,4,5,6,7,8,9,10})))*.96
    This formula worked in Excel and when I converted my spreadsheet over to Numbers, this formula no longer works.
    The best that I have been able to do so far is use small in 10 different cells, then get the average of the 10 cells and finally multiply that average by .96  So instead of using 1 cell, I'm using 12 cells to get my answer.
    This is a formula that I will be using all the time. The next cell would be =(average(small(H202:H221,{1,2,3,4,5,6,7,8,9,10})))*.96
    Hoping I explain myself well enough and that someone can help me.
    Thanks

    You can still do it in one cell but it will be more unruly than the Excel array formula.
    =average(small(H201:H220,1),small(H201:H220,2),small(H201:H220,3),...,small(H201:H220,10))*0.96
    where you would, of course, replace the "..." with the remaining six SMALL functions.

  • On my wireless printer can i use both usb and wireless at the same time

    i tried to print from coupons,com but it will not  i have used coupons.com before with my other printer and weorked fine i have coupons.com looking into it
    just wondering if anyone else out there have the same problem

    Hi,
    Same physical printer but when connecting to SAME computer using both USB and wireless it becomes two (logical) printers. Probably your default prnter is the wireless one, you have to select the right printer before print .
    Regards.
    BH
    **Click the KUDOS thumb up on the left to say 'Thanks'**
    Make it easier for other people to find solutions by marking a Reply 'Accept as Solution' if it solves your problem.

Maybe you are looking for