How to divide result in 80/20

Hi
I have bit different requirement.
I have table A which has 1000 records.
Now I was insert 80% of record from table A into Table B80
and remaining 20% in C20
How can I do that.

A more generic way using a single insert statement would be something like...
insert all
  when grp = 0 then
    into b80 (... columns ...)
    values (... columns ...)
  when grp = 1 then
    into c20 (... columns ...)
    values (... columns ...)
select ... columns ...
      ,case when row_number() over (order by 1) / count(*) over () <= 0.8 then 0 else 1 end as grp
from ae.g.
SQL> create table emp80 as select * from emp where 1=0;
Table created.
SQL> create table emp20 as select * from emp where 1=0;
Table created.
SQL> select * from emp80;
no rows selected
SQL> select * from emp20;
no rows selected
SQL> ed
Wrote file afiedt.buf
  1  insert all
  2    when grp = 0 then
  3      into emp80 (empno, ename, job, mgr, hiredate, sal, comm, deptno)
  4      values (empno, ename, job, mgr, hiredate, sal, comm, deptno)
  5    when grp = 1 then
  6      into emp20 (empno, ename, job, mgr, hiredate, sal, comm, deptno)
  7      values (empno, ename, job, mgr, hiredate, sal, comm, deptno)
  8  select empno, ename, job, mgr, hiredate, sal, comm, deptno
  9        ,case when row_number() over (order by 1) / count(*) over () <= 0.8 then 0 else 1 end as grp
10* from emp
SQL> /
14 rows created.
SQL> select * from emp80;
     EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
      7369 SMITH      CLERK           7902 17-DEC-80        800                    20
      7499 ALLEN      SALESMAN        7698 20-FEB-81       1600        300         30
      7521 WARD       SALESMAN        7698 22-FEB-81       1250        500         30
      7566 JONES      MANAGER         7839 02-APR-81       2975                    20
      7654 MARTIN     SALESMAN        7698 28-SEP-81       1250       1400         30
      7698 BLAKE      MANAGER         7839 01-MAY-81       2850                    30
      7934 MILLER     CLERK           7782 23-JAN-82       1300                    10
      7788 SCOTT      ANALYST         7566 19-APR-87       3000                    20
      7839 KING       PRESIDENT            17-NOV-81       5000                    10
      7844 TURNER     SALESMAN        7698 08-SEP-81       1500          0         30
      7876 ADAMS      CLERK           7788 23-MAY-87       1100                    20
11 rows selected.
SQL> select * from emp20;
     EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
      7900 JAMES      CLERK           7698 03-DEC-81        950                    30
      7902 FORD       ANALYST         7566 03-DEC-81       3000                    20
      7782 CLARK      MANAGER         7839 09-JUN-81       2450                    10
SQL>

Similar Messages

  • How to compare result from sql query with data writen in html input tag?

    how to compare result
    from sql query with data
    writen in html input tag?
    I need to compare
    user and password in html form
    with all user and password in database
    how to do this?
    or put the resulr from sql query
    in array
    please help me?

    Hi dejani
    first get the user name and password enter by the user
    using
    String sUsername=request.getParameter("name of the textfield");
    String sPassword=request.getParameter("name of the textfield");
    after executeQuery() statement
    int exist=0;
    while(rs.next())
    String sUserId= rs.getString("username");
    String sPass_wd= rs.getString("password");
    if(sUserId.equals(sUsername) && sPass_wd.equals(sPassword))
    exist=1;
    if(exist==1)
    out.println("user exist");
    else
    out.println("not exist");

  • How to display results set of multiple reports into a single report table

    Our goal is to create a single report (or dashboard) that shows the "funnel" of object creations related to each campaign. The flow goes from Activity to Lead to Opportunity as well as multiple steps within each (ie. Unqualified Lead -> Qualified Lead, etc).
    We currently have 3 separate reports in three different subject areas, each reporting the different metrics and we would like to combine the output into a single Unified report.
    For example what we currently have is:
    Activities:
    Campaign Name # of Activities
    Campaign A 12
    Campaign B 26
    Leads:
    Campaign Name # of Leads # of Qualified Leads
    Campaign A 10 4
    Campaign B 20 18
    Opportunities:
    Campaign Name # of Opportunities # of Opps per Sales Stage ... # of Wins Closed Revenue
    Campaign A 3 2 1 $1,000.00
    Campaign B 10 8 3 $2,800.00
    What we want to see is:
    Combined:
    Campaign Name - Campaign Cost - # of Activities - # of Leads - # of Qualified Leads - # of Opportunities - # of Opps per Sales Stage - # of Wins - Closed Revenue
    Campaign A - $423.00 - 12 - 10 - 4 - 3 - 2 - 1 - $1,000.00
    Campaign B - $ 1,000.00 - 26 - 20 - 18 - 10 - 8 - 3 - $2,800.00
    We have tried using the "Combine with similar analysis" but the number of columns for each subject area differ. We also tried creating multiple UNION criteria (one for each column), but in the case of # of Opps per Sales Stage and Closed Revenue, those are not "Metrics" fields, so they won't combine.

    Hi, You may have to create some dummy fields to equate the no. of field in each of the report matching the data type too and get a one single report using combined analytics and then using the resultant data you can create a simple pivot like below. Haven't tried it before
    -- Venky CRMIT
    Hi Venky,
    I am facing the same problem. Can you please say Steps how to create resultant data and Combine in pivot Table .
    Please Help me .
    Thanks in Advance .
    My mail id is :
    [email protected]

  • How to divide all textFrames in one-character-per-textFrame?

    Hello:
    How to divide all textFrames in one-character-per-textFrame?
    Example: the textFrame "Letters" will be divided in 7 textFrames: "L", "e", "t", "t", "e", "r", "s".
    Help, please.

    Hi Paul, try this one
    #target Illustrator
    //  script.name = splitSelectedFramesIntoWords2.0.jsx;
    //  script.description = splits selected texFrames into separate words;
    //  script.required = select point text textFrames before running;
    //  script.parent = CarlosCanto;  // 10/14/11
    //  script.elegant = false;
    var idoc = app.activeDocument;
    var sel = idoc.selection; // get selection
    var selCount = sel.length; // count items
    var tFrames = []; // to hold the textFrames
    for (j=selCount ; j>0 ; j--) // loop thru selection & get textFrames backwards
                        tFrames[j-1] = sel[j-1];
    for (k = 0 ; k<tFrames.length ; k++) // loop thru textFrames
                        var xpos = tFrames[k].position[0]; // get x
                        var ypos = tFrames[k].position[1]; // get y
                        var words = tFrames[k].contents.split(/\s/g); // get all words into an array
                        //$.writeln(words);
                        var space = tFrames[k].duplicate(); // dup to get width of a space
                        space.contents = " ";
                        var sw = space.width;
                        space.contents = words[0]; // replace space with first word
                        var w = space.width;
                        var wordCount = words.length; // count words
                        for (i=1; i<wordCount ; i++) // loop thru words
                                            xpos2 = xpos+w+sw; // next words position = previous word pos+width+space
                                            var iword = space.duplicate(); // duplicate previous word
                                            iword.contents = words[i]; // add next word
                                            iword.position = [xpos2,ypos]; // position the character = original position + new width
                                            w = iword.width; // get words width
                                            xpos = iword.position[0]; // get words position
                        tFrames[k].remove(); // remove textFrame

  • Who knows: How to divide the request.getInputStream()?

    I use a form in a web page to update files, the form code is
    <form action="/Mywork/servlet/fileupdate1" method="post" enctype="multipart/form-data">
    <p>
    Please select a file1 to upload: <input type="file" name="foo">
    </p>
    <p>
    Please select a file2 to upload:<input type="file" name="foo1">
    </p>
    <input type="submit" value="Upload File!">
    </form>
    and the "fileupdate1" servlet which the "action" in the form tag refers to will get the inputstream by
    "ServletInputStream servIn = request.getInputStream();", and create new OutputFileStream in the disk. But
    new files which the servlet stored always have some additional codes "
    -----------------------------7d419320202be
    Content-Disposition: form-data; name="foo"; filename="H:\Documents and
    Settings\administrator\desktop\ee.java"
    Content-Type: application/octet-stream
    If I updating two files, each file will has these kinds of codes and the two files only have one inputstream. I don't
    how to remove these additional codes and how to divide the stream into pieces according to the updated-file-size.
    I don't know wether I say it clearly?And
    does anyone know the reasons and can help me?
    Thank you very much.

    Use something like Jakarta Commons FileUpload to process the multipart/form-data request:
    http://jakarta.apache.org/commons/fileupload/

  • How to divide a grid (an 2D array) into subgrids? [Suduko]

    Hey guys
    I've been struggling with a problem with my Suduko program for a few days now and thought I could get some help here.
    The problem is that I have no idea how to divide a Suduko grid and stuff them into subgrids.
    My current plan is to go through the Suduko array r * c times (where r and c is the dimensions of a subgrid) and stuff the cells into my quad array (somehow). I've gone through the sourcecode of 4 suduko programs on sourceforge, but still can't find a solution (mainly because I can't read other prog. lannguages yet).
    My code:
    * easyIO is a packadge that enables read/write to files
    * and enables communication between the user and the program via the command-line
    * You can find this packadge here: http://www.universitetsforlaget.no/java/easyIO.zip
    import easyIO.*;
    /** Initialises the board */
    class Oblig2
         public static void main(String[] args)
              /** If there is a argument in the command line (the filename to be used in this case),
               *  then send that argument with a new Board
              if(args.length >= 0)
                   Board suduko = new Board(args[0]);
    class Board
         /** Constant (yeah, no final int) that defines the board dimensisions, if dimension is 6, then the board is 6 x 6 */
         int dimension;
         /** The quad dimensions */
         int quadRow;
         int quadCol;
        Cell[][] cells;
        Row[] row;
        Col[] col;
        Quad[] quad;
         * Board contructor defines the boards properties
         * @param filename comes from Oblig2.main()
        Board(String filename)
              /** In is a class of easyIO, inFile will contain the contents of the file */
              In inFile = new In(filename);
              dimension = inFile.inInt("\n"); System.out.print(dimension + "\n");
              quadRow = inFile.inInt("\n"); System.out.print(quadRow + "\n");
              quadCol = inFile.inInt("\n"); System.out.print(quadCol + "\n");
              inFile.readLine();
              /** Creates all the neccessary cell, row, cols and quad arrays */
              cells = new Cell[dimension][dimension];
              row = new Row[dimension];
              col = new Col[dimension];
              quad = new Quad[quadRow * quadCol];
              /** Initializes all the rows */
              for(int i = 0; i < row.length; i++)
                   row[i] = new Row(dimension);
              /** Initializes all cols */
              for(int i = 0; i < col.length; i++)
                   col[i] = new Col(dimension);
              /** Initializes all quads */
              for(int i = 0; i < quad.length; i++)
                   quad[i] = new Quad(quadRow, quadCol);
              /** Initializes all cells and puts them in rows and cols */
              for(int i = 0; i < cells.length; i++)
                   for(int j = 0; j < cells.length; j++)
                        cells[i][j] = new Cell();
                        row[i].addCell(cells[i][j]);
                        col[j].addCell(cells[i][j]);
                        cells[i][j].addRCpointer(row[i], col[j]);
              for(int i = 0; i < (quadRow * quadCol)
                   for(int j = 0; i < cells.length; j++)
                        for(int k = 0; k < cells[k].length; k++
              /** Reads the file until it reaches the end of the file */
              while(!inFile.endOfFile())
              /** Closes the filecontainer */
              inFile.close();
    class Row
         /** Single col. array to contain cells in row */
         Cell[] row;
         * Assigns an array with length=rowVal
         * @param is the same as dimension in Board-class
         Row(int rowVal)
              row = new Cell[rowVal];
         /** Add cell to row
         * If the cell is null, or empty, then it will set the cell[i] = cell,
         * and return control back to the caller
         void addCell(Cell cell)
              for(int i = 0; i < row.length; i++)
                   if(row[i]==null)
                        row[i] = cell;
                        return;
         * Checks if it's possible to stuff a number into the row,
         * returns true if it's possible and false else
         boolean tryNumeral(int cellVal)
              for(int i = 0; i < row.length; i++)
                   if(row[i].getContains() == cellVal)
                   { return false; }
              return true;
    class Col
         /** Single col. array to contain cells in col.*/
    Cell[] col;
    * Assigns an array with length=colVal
    * @param is the same as dimension in Board-class
    Col(int colVal)
              col = new Cell[colVal];
         /** Add cell to col.
         * If the cell is null, or empty, then it will set the cell[i] = cell,
         * and return control back to the caller
         void addCell(Cell cell)
              for(int i = 0; i < col.length; i++)
                   if(col[i]==null)
                        col[i] = cell;
                        return;
         * Checks if it's possible to stuff a number into the col,
         * returns true if it's possible and false else
         boolean tryNumeral(int cellVal)
              for(int i = 0; i < col.length; i++)
                   if(col[i].getContains() == cellVal)
                   { return false; }
              return true;
    class Quad
         /** Single col. array to contain cells in quad*/
    Cell[] quad;
         /** Assigns an array with length=row*col to quad */
    Quad(int row, int col)
              quad = new Cell[row * col];
         /** Add cell to quad
         * If the cell is null, or empty, then it will set the cell[i] = cell,
         * and return control back to the caller
         void addCell(Cell cell)
              for(int i = 0; i < quad.length; i++)
                   if(quad[i]==null)
                        quad[i] = cell;
                        return;
         * Checks if it'possible to stuff a number into the quad.
         * returns true if it's possible and false else.
         boolean tryNumeral(int cellVal)
              for(int i = 0; i < quad.length; i++)
                   if(quad[i].getContains() == cellVal)
                   { return false; }
              return true;
    /** The lowest unit on a Suduko board */
    class Cell
         /** The number the box contains */
    int contains;
         /** Pointers to the row/col/quad it's located in */
    Row cellRow;
    Col cellCol;
    Quad cellQuad;
         /** Add pointers from Board-contructor R = Row, C = Col. */
         void addRCpointer(Row row, Col col)
              cellRow = row;
              cellCol = col;
         /** Checks if it's okay to place a number there */
    void tryNumeral()
    /** Get-method for the cells value */
    int getContains()
              return this.contains;

    nitinkajay wrote:
    I want to know how to store the output of a analog to digital converter into an 2D labview array.
    How exactly are you performing 'Analog to Digital'???
    Grabbing image using camera OR performing data acquisition using DAQ card OR some other way????
    I am not allergic to Kudos, in fact I love Kudos.
     Make your LabVIEW experience more CONVENIENT.

  • How to divide the request.getInputStream()?

    I use a form in a web page to update files, the form code is
    <form action="/Mywork/servlet/fileupdate1" method="post" enctype="multipart/form-data">
    <p>
    Please select a file1 to upload: <input type="file" name="foo">
    </p>
    <p>
    Please select a file2 to upload:<input type="file" name="foo1">
    </p>
    <input type="submit" value="Upload File!">
    </form>
    and the "fileupdate1" servlet which the "action" in the form tag refers to will get the inputstream by
    "ServletInputStream servIn = request.getInputStream();", and create new OutputFileStream in the disk. But
    new files which the servlet stored always have some additional codes "
    -----------------------------7d419320202be
    Content-Disposition: form-data; name="foo"; filename="H:\Documents and
    Settings\administrator\desktop\ee.java"
    Content-Type: application/octet-stream
    If I updating two files, each file will has these kinds of codes and the two files only have one inputstream. I don't
    how to remove these additional codes and how to divide the stream into pieces according to the updated-file-size.
    I don't know wether I say it clearly?And
    does anyone know the reasons and can help me?
    Thank you very much.

    Well, if you know the format, you'd know that the file data starts after the first blank line (\r\n\r\n).
    But why don't you just use Jakarta Commons File Upload or some other existing free package to handle multipart forms and save yourself the trouble.

  • How to divide clip into separate shots?

    When I capture a full tape, I always receive one clip (file). How to divide it into separate shots?

    What format are you working in? What version of the software?
    Maybe this will help
    http://www.fcpbook.com/Video5.html

  • How to display result of database query in JFrame?

    How to display result of oracle database query in JFrame?
    This is part of my code:
    String username, password;
              DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
              OracleConnection conn = DriverManager.getConnection(String url, String username, String password);
    Statement s= conn.createStatement();
    ResultSet q= s.executeQuery("SELECT A, B, C FROM TABLE X");
    Forget what url, username & password are. Is there any problem with my code?
    What should be next if I want to display result of the query in a table in JFrame?Thx !

    How to create JTable with unknown no. of rows? How to get no. of rows of a query?
    I saw the demo of creating JTable on java.sun.com but the the table has a certain no. of rows which is not applicable to my case.
    Suppose the result of query is a table with 3 attributes so there are 3 columns in the table.
    R contains the result of the query.
    Should it be something like this if I want to create JTable of the query?
    How to make n rows of {R.getString(1),R.getString(2),R.getString(3)};?
    public SimpleTableDemo() {
    super(new GridLayout(1,0));
    String[] columnNames = {"A",
    "B",
    "C",
    while (R.next())
    // content of a row
    Object[][] data = {R.getString(1),R.getString(2),R.getString(3)};
    I can't run it because I still can't debug my code which is said before.
    Thx!

  • How to suppress Result rows in a Query in Web Application Designer

    Hi
                 I am trying to post a query in Web Application Designer. I am able to run the query in WAD but the Results rows appear. I choose Suppress Result Rows always in All Characteristics option in the query in BEx Explorer but still i see result rows in the WAD. Can anyone please let me know how to suppress Result rows so that they dont appear in Web Application Designer.
    Thanks,
    Padma

    To get the enhanced menu-
    1. Open the template in WAD.
    2. Go to Web Item properties.
    3. Go to Entries in Context Menu.
    4. Find the "Enhanced Menu" property. Set it to "display" if you want it to be visible in template result.
    5. Next time when you execute your template you will be able to access it by right clicking.
    or
    If you just want to supress results without adding enhanced menu in the context menu, simply set "Calculate result as" to "No Display".

  • How to filter results from 4 dynamic list menus depandant on how many of them are selected

    I have a search page with a form with 4 list menus and 1 submit that post the results to the results page. I can create a record set that either retrieves the correct data from my database if a selection is made from all four menus Or i can create the recordset if only 3 menus have a selection or the same for 2 menus and 1 menu. However i want the user to be able to make a selection from either 1, 2, 3 or all 4 of the menus and the exact data be retrieved. At present if i try to combine the recordset using AND and ORs the results are not specific enough, for example the 4 menus are Location, Type, Price & Style if a user selects from all 4 i only want to retrieve data that matches all 4 criteria, but at the same time if the user selects only 2 of the menus the i want it to retrieve data that matches specifically those 2 variables. I´m not actually sure if i should be creating a more advanced sql query of if its the php side of things that i need to look at. This is my first dynamic site so please be aware i´m still a learner where php and sql is concerned. Please can anyone help?  

    Hey there,
    Thanks for replying,
    I too am using Dreamweaver recordset, my local server is XAMPP ( apache php mysql), i´have pasted my sql recordset below to give an idea of what i´m trying to do, however this does not work as i´m trying to select the exact data based on 4 menus PRICE TYPE LOCATION and BEDS, and also want the search to work if the user only selects options from either 1, 2, 3 or 4 of the menus, with the code as it is if the user select only two options from 2 of the menus the results don´t just find (for example) all results for location AND price they find all results for the location varibale OR the price variable rather than a match for both, if you see what i mean?
    Any suggestions?  
    SELECT trueprice,`desc`, `propid`, `bathrooms`, `photo1`, locationtable.loc, typetable.style, bedtable.`number`
    FROM detailstable JOIN locationtable ON detailstable.location=locationtable.locid JOIN typetable ON detailstable.type=typetable.typeid JOIN pricetable ON detailstable.price=pricetable.priceid JOIN bedtable ON detailstable.beds=bedtable.bedid
    WHERE (location=varloc AND price = varprice AND type=vartype AND beds=varbed ) OR (price=varprice AND location=varloc AND type=vartype) OR  (price=varprice AND location=varloc AND beds=varbed) OR (price=varprice AND beds=varbed AND type=vartype) OR  ( location=varloc AND type=vartype AND beds=varbed) OR  (price=varprice AND location=varloc) OR (price=varprice AND type=vartype) OR (price=varprice AND beds=varbed) OR (type=vartype AND location=varloc) OR (type=vartype AND beds=beds) OR (location=varloc AND beds=varbed) OR (price = varprice OR beds=varbed OR type=vartype OR location=varloc)
    ORDER BY detailstable.trueprice ASC
    Look forward to receiving your thoughts,
    Linda
    Date: Wed, 21 Oct 2009 14:36:33 -0600
    From: [email protected]
    To: [email protected]
    Subject: how to filter results from 4 dynamic list menus depandant on how many of them are selected
    Hiya,
    I'm just doing my first dynamic site too, and am at a similar level to yourself.
    Can you give us more info re the site. What software, eg Dreamweaver etc are you using, and is your server using PHP or ASP etc?
    For what I've used, I amended the SQL side of things in the recordset in Dreamweaver. That way, you can test the SQL as you're setting up the recordset.
    Let me know how you're going on anyway
    Cheers
    Andy
    >

  • How to divide the partitions in AIX 5L

    Hi Guru's
    Friends i am installing AIX 5L, How to divide the partitions in AIX5L
    please tell me if anybody know.
    Thanks

    What kind of partitions do you mean? Do you mean logical partitions?
    Message was edited by:
    Ivan Kartik

  • How to divide the CRM transaction data by company cord?

    How to divide the CRM transaction data by company cord?
    CRM transaction have not company cord, so how to divide the data on BI report by company cord?
    Do I have to get the sales organization from customer master?
    Some transactions have not master data like lead. I want to know your experience.

    Hi
    This is self reply.
    I should use the sales organization instead of company cord.
    But some business like lead from contact from customer can not separate the company, in situation one call center for multiple companies.
    We should use another field to divide the company. Ex. Product, campaign, etc.
    If someone knows better way to solve this issue, let me know the reply.
    Regard
    u1

  • How to divide the iview into frames?

    Hi Experts,
                  Please tell me how to divide the iview into frames.Kindly provide the   steps.Its urgent.
    Regards,
    Nutan

    Hi Nutan,
    Now its clear!!
    If I understand right. You want an overview page full of links to go to your different pages?
    Or maybe you want a link form each page to go to another page?
    In Portal Navigation through hyperlinks is possible.
    You can either do that using EPCM.doNavigate("ROLES://...") {check for EPCM API of help.spa.com}
    Or you could do that by simple
    <a href="http://www.sdn.sap.com/irj/portal/myql">CLICK</a>
    {check for Quicklinks on help.sap.com}
    Either way you'll have to make a small JSP for that.
    Hope this helped
    If so kindly reward with points
    Prem

  • How to divide SAPS when having two instances on same host

    Hello
    I wander how to divide SAPS when having two instances on same host. By looking at st06?
    Thank you in advance

    Yes SAPS is nothing but the CPU power used by the SAP systems. SO if you have 2 SAP systems stacked on the same server, check the CPU utilization over a period of 7 - 10 days, average out & that should give you a fair bit of idea.
    - Regards, Dibya

Maybe you are looking for