Divide the extracted almost lines also and assign a group

Hi all

I have the table:

Oracle Database 10g Enterprise Edition Release 10.2.0.4.0-
SQL> select * from upd;

         A B
---------- ----------
         1 xxxx
         2 xxxx
         3 ddd
         4 d
         5 t
Suppose I have only 5 groups and each group can have only 2 rows, example:

assign the 2 rows to G1, G2 and G3 2 ranks, still something like
      A B            Group
---------- ---------- 
         1 xxxx       G1
         2 xxxx       G1
         3 ddd        G2
         4 d            G2
         5 t            G3
Help, please

Published by: user8650395 on November 8, 2009 01:13

Hello

Analytical NTILE function could do that:

SQL> with upd as (  -- generating sample data:
  2  select 1 a, 'xxxx' b from dual union all
  3  select 2, 'xxxx' from dual union all
  4  select 3, 'ddd' from dual union all
  5  select 4, 'd' from dual union all
  6  select 5, 't' from dual
  7  )
  8  --
  9  -- actual query starts here:
 10  --
 11  select a
 12  ,      b
 13  ,      'G'||ntile(3) over (order by a) grp
 14  ,      ntile(3) over (order by a) ntile_result
 15  from   upd;

         A B    GRP                                       NTILE_RESULT
---------- ---- ----------------------------------------- ------------
         1 xxxx G1                                                   1
         2 xxxx G1                                                   1
         3 ddd  G2                                                   2
         4 d    G2                                                   2
         5 t    G3                                                   3

See: http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/functions101.htm#SQLRF00680

Tags: Database

Similar Questions

  • I don't remember the password for my network, but I do remember the password for my computer and my home group.

    I don't remember the password for my network, I remember the password to my computer and my home group, they are all different to change that, but family crisis distract me unable to use my ipad now or my other computer help!

    original title: password

    Hello

    What operating system is installed on the computer?

    Perform the steps mentioned below, if you have Windows 7 installed on the computer and see if the problem persists.

    a: right click on the wireless in your taskbar icon.

    b: open network and sharing Center and then click manage wireless networks on the left.

    c: you will see all the networks you have connected too.

    d: right click on any connection to Properties.

    e: click on the Security tab that shows the details of the security of the network including the password. Click on the box to Show characters.

    Hope this information helps.

  • No way to stop 'Dash' to also lower the 20px almost line?

    With the help of "Withdrawal" in the body of a text of the e-mail always simultaneously reduce the position of the line about 20px? Is it possible to change this - maybe through the configuration editor?

    Thank you, in advance!

    It seems that the style of integrated dash inserts a paragraph break. Your most likely solution is to use something like https://addons.mozilla.org/en-US/thunderbird/addon/stationery/ and re - define styles to your taste. I'm sorry that I can't offer you a simpler solution.

  • The user select several shapes and assign the variable

    Hello

    I worked mainly Storyline articulate and now I'm back in Captivate 8 I really miss simplicity of the scenario

    I need to create a very simple interaction "select all the boxes." I want the text in boxes and the user to select as much as they wish (there are 10 in total) and that selected they should change their 'down' State, so it is obvious that they have enabled the box on and then a variable is assigned to show later in the course.

    I told the Action for the award of variable when the user clicks on but just slide forward and I can't select several options. Also, there is a pause on the button continue for the slide does not move on to the next.

    Can someone tell me how I can do this SIMPLE interaction quickly?

    A simple action will always be out of reading, replace it with a standard advanced action (can be a single line, but I think you will need more than one).

    Why choose Standard Simple action? -Captivate Blog

    It also has a link to a YouTube video.

    Keep with scenario then... for me it's very simple, but that's just me.

    What should be stored in the variable? The number of texts chosen? Or do you want a text variable and change this variable from 0 to 1 if the corresponding text is selected?

    Why not use the interaction of checkboxes? It's pretty simple to use, it will store the answers selected in the variables.

    If you explain better what you want to, have solutions for all situations.

  • divide the data into lines

    Hello

    I have data like this.


    Person_wid industry

    111 car; Telecom


    How to divide as below


    Output:

    Auto 111

    Telecom 111


    Thank you


    SQL > test as

    () 2

    3 select person_wid 111, ' car. Telecom' double industry

    4)

    5. Select person_wid

    regexp_substr 6, (industry, ' [^;] +', 1, rn) split

    7 test

    8 cross

    9 join (select rownum rn

    10 in (select max (length (regexp_replace (industry, ' [^;] +'))) + 1 mx)

    11 test

    12                 )

    13 connect by level<=>

    14         );

    SPLIT PERSON_WID

    ---------- ------------------

    Auto 111

    Telecom 111

    2 selected lines.

    Notes on the Oracle: split delimited by a comma the way of RegExp string, second part

  • How to change the font, color line, column and Grand Total labels in PivotTable

    Hello Guru

    Can you get it some one please let me know how to change the look and feel of the reports in Pivot table using css files. I want to have the dimension and the measure to be of different color columns and grand total different color. I want to achieve for all pivot table reports instead of manually change each report so I want to do in css files.under s_SRIKI\b_mozilla_4\views.css I've seen a lot of options but nothing has worked. So can you please exactly tell what class we need to change to make changes. Thank you!!!

    Thank you

    SR

    For values

    . OORT {}

    text-align: right;

    vertical-align: top;

    color: Red;

    }

    For the product if you got hyper link

    Code OOB is

    . PTL {}

    color: #039;

    text-decoration: none;

    cursor: pointer;

    }

    If brand aid

  • How to display the column single line with function of nested groups

    SQL > select deptno, Max (sum (sal)) SalSum
    2 of PEM
    3 Group of deptno;
    Select deptno, Max (sum (sal)) SalSum
    *
    ERROR on line 1:
    ORA-00937: not a single group group function

    Can you please help me to get the Max (sum (sal)) with Deptno...

    Or:

    select max(deptno) KEEP (DENSE_RANK LAST ORDER BY SalSum) deptno,
    max(SalSum) from  (
      select deptno,sum(sal) SalSum
      from emp
      group by deptno
    );
    
  • Unlike used MB of available space in the ASM disk between primary and standby database group

    Hi all

    We are seeing a difference in ASM disk group DATA1 USED_MB between elementary school a Standby.Its an AAM.4 node RAC

    Primary

    -------

    NAME                              TOTAL USED GB FREE GB REQUIRED FREE GB USABLE % USABLE free of CHARGE (GB)

    ------------------------------ ------------ ------------ ------------ ---------------- ---------------- --------------

    Data1 141 534 66 082 75 452 15 726 42.0 59 726

    DATA_XDP501 17 766 11 635 6 131 2 538 3 593 20.0

    Standby

    NAME                              TOTAL USED GB FREE GB REQUIRED FREE GB USABLE % USABLE FREE (GB)

    ------------------------------ ------------ ------------ ------------ ---------------- ---------------- --------------

    Data1 141 534 57 059 84 475 15 726 68 749 49.0

    DATA_XDP801 17 766 11 781 5 985 2 538 3 447 19.0

    Mode standby is runnig like

    OPEN_MODE

    --------------------

    READ ONLY TO APPLY

    Some body give an overview on what could be the purpose or specific controls will help

    Thank you

    Soundar.M

    Hello

    You can run sql in below document ASM sqlplus.

    Then, you will come to know which files are files of redundent on ASM diskgroup.

    HOW to map ASM FILES WITH FILES of DATABASE ONLINE (Doc ID 552082.1)

    Delete these additional level of the DSO files, then validate.

    Kind regards
    Loriette

  • the number of lines committed themselves to variable

    Hello

    of in plsql I do

    insert into t_target (...) select (fields, fields, fields) of sourcetable.
    commit;


    I want to capture the number of lines committed and assign it to a variable or insert it into a table, I can't count on
    County of table source or t_target because both these tables change through the day / data are inserted and removed those
    tables. is it possible

    Thank you

    Declare a variable and assign the number of lines to this variable.

    As...

    insert into t_target (...) select (fiels,fields,fiels) from sourcetable; 
    
     v_count := SQL%ROWCOUNT;
    commit;
    
  • Update of custom table and column based on the number of lines inserted in it.

    Hello

    I have a XX_TDP_DT custom table that has a column ID_processus.
    User will be be download data in the XX_TDP_DT table, but they insert any value into ID_processus.
    Say if the entered data are 1000 lines.
    I need to process these 1000 rows in batches, so I want to have 1 for 1 to 200 rownum = ID_processus, ID_processus = 2 for rownum 201 to 400 and so on.
    How can I achieve this, any suggestions?

    Database: 10g

    Thank you.

    You can also use NTILE to do this, see:
    Re: Divide also extracted almost lines and assign a group
    http://asktom.Oracle.com/pls/Apex/f?p=100:11:0:P11_QUESTION_ID:47910227585839

  • Extract Pages... and the Split... do not do what I expect

    I have a document created in Illustrator (CS4), which has several work plans. I want that it split into several documents, Board of Directors an art - > a document with only this work. When I use the extract PAges... and the Split... orders to generate multiple documents, I get the multiple docs (same number of documents created as pages in the original document).

    The only thing is that every doc has all work plans and all works of art like the original doc. I couldn't understand all the works of art being there but all the plans of work also? What is going on?

    Appreciate the pointers on this.

    Writing a JSX to run in artificial intelligence, but hurt so far. Wire for solution started here: AS) export PDFs single page of work multi-plans

    No worries.  Just try to get a handle on the issue.  I think that we are talking in different worlds.  I wrote to the Acrobat and PDF software for 10 years, printing, processing documents, forms, etc. name you it.  I have never worked with Illustrator, never heard of work plans and never seen references that you use.

    see you soon,

  • My audio is on the Audio Digital (S/PDIF), and I have NO SOUND.

    The problem is started when installing windows 7 on my desktop, or when installing a new audio or video card I'm not positive exactly when it started to happen. But all of a sudden the audio device only I got was Audio Digital (S/PDIF), which in fact did nothing.

    I figured out how to get the speakers on my monitor to work, I plugged the speaker cable into the port 'in line', blue and stakeholders have worked.  The cord is green light... the port is blue... it doesn't look right, it seems that it should be in the green port right? But it does not work like that.

    Anyway if I plug the monitor or headphones on in blue 'line' port it affects my speakers 'Speakers' "high definition Audio Device".  And I have audio.

    But I need to have a microphone that works as well for a class I have. But when I plug the headphones that it doesn't work, it doesn't recognize the microphone or even acknowledge that I plugged anything.  The helmet part works by plugging in 'line' port, but the microphone does not work.  He said that the recording device is set to Audio Digital (S/PDIF) and nothing else is listed in Device Manager.

    I have seen this problem posted elsewhere and I followed a lot of steps, I tried to download drivers realtek, windows update, update drivers for my Nvidia graphics card, and I even download Everest to be sure of my Audio device. It's what came SigmaTel STAC9220 A1 @ Intel 82801 GB ICH7 - High Definition Audio Controller [a-1].  The link to update the drivers was useless, but I looked online and found one on the site of Dell, he said it was for Sigma Tel STAC92XX... which should include mine.  I downloaded it, rebooted, and all of a sudden I got no. AUDIO DEVICE AT ALL.  Windows said I had no sound, and he tried to install the drivers, although I'm sure that I had done that we found my Sigma Tel Audio Controller.  Windows cannot install the, then suddenly he tried again and said it was successful.  But I'm right back where I started, still consider the Audio Digital (S/PDIF) is my recorder, speakers do not work unless it is plugged into the blue port in 'line '.   Nothing has changed...

    If anyone can help please let me know. I appreciate it.

    It happened to me, I just unplug and reconnect the plug and she is back to normal

  • How to create and assign a VLAN to specific ports

    In our ISA550W, create the VLANS for different subnets and assigning them to specific ports are a piece of cake and self explanitory.

    However on a SG300-10MP, I am totally lost lol. I just want to make ports 7 & 8 set to a sous-reseau.10 instead of un.6 as the rest of the switch. I need these ports to be totally independent from the rest and not to communicate with others at all.

    How can I do this?

    Thank you!

    Hi Alex,

    Under management of VLANS, go into settings of the interface.  Change the interfaces that you use to access the ports by choosing the way you want by clicking on change.

    Once they are access ports back to Port for page VLAN and assign the port desired as one not marked in this interface.

    This should be everything you need, let me know if you have any other questions.

    -Good Trent

    * Please note the useful messages! **

  • How to get the default rotation tool locate the pivot point in the exact Center of an object or a group of objects?

    My new copy of the CC the default pivot set to one side, rather than at the center point. I know I can manually move the autour pivot point, but this is not always accurate. Is there a way to have HAVE determine exactly at the Center and then do this by default?

    Pivot the tool rotation default to the center of objects and the text box (frame). For text of Point, it is by default the anchor of the line base, and for a group of Point text objects, or multi-selction defaults to the geometric center of an invisible shape formed by the collective reference anchors.

    And you are right, that the setting of Center in the attributes Panel is not available for text of Point, single or multiple objects.

    I don't have an idea for your particular workflow needs, but if I really need to turn a group of objects text around its Center Point, I could do this:

    1. Select the group, and copy
    2. Paste in front
    3. Vectorize
    4. Select the converted objects and text objects group, then select the rotation tool and the pivot will be by default the Center (of the converted objects)
    5. After turning, remove the converted objects.
  • Why is my screen blurry and lines undulate on the sides? It also keeps the glitter!

    Why is my screen blurry and lines undulate on the sides? It also keeps the glitter!

    Is your very large monitor, like an old TV or flat, as perhaps a few inches thick?  If it is very deep (front to back), you have an old style monitor, and they need to be demagnetised every now and then. Look on the monitor for the menu button and navigate until you find an icon like a horseshoe with a bar slash through it (or like a magnet) and select it.  All wavy and colorful display for one minute and then went back to normal. Also, make sure that all the cables between the monitor and your computer are firmly connected at both ends, even if you have a thin screen.

    If you have a laptop, try to turn the screen and see if the blur changes.  If so, you might have a connector loose inside and may need to be considered at a repair shop. =(

    Best luck!

    (There is a small chance it is a result of burn; made me know if any of them help you, or that they do not apply.)

Maybe you are looking for