How i achive this data by writing exact query ?

Dear Exparts,
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Prod
PL/SQL Release 10.2.0.3.0 - Production
"CORE     10.2.0.3.0     Production"
TNS for 32-bit Windows: Version 10.2.0.3.0 - Production
NLSRTL Version 10.2.0.3.0 - ProductionI have a table Name TB and Column A and B with the following data.
A       B
10     02-AUG-2012
10     04-AUG-2012
10     01-SEP-2012
10     10-AUG-2012
11     04-AUG-2012
11     01-SEP-2012
11     01-AUG-2012
10     12-AUG-2012
10     15-JUL-2012I need data like
A                      B
10            10-AUG-2012
10            12-AUG-2012
10            01-SEP-2012
11            01-SEP-2012How we get this data ?
We have to count column B group by Column A. then devided the count_value by 2 and trunc it and base on the result out put will come. the data are the maximum data.
Like when we count group A result will be
A            B
10           3
11           1base on above result my desire outpul will come...
Here is the script
CREATE TABLE TB
    "A" VARCHAR2(20 BYTE),
    "B" DATE
Insert into TB (A,B) values ('10',to_date('02-AUG-2012','DD-MON-RRRR'));
Insert into TB (A,B) values ('10',to_date('04-AUG-2012','DD-MON-RRRR'));
Insert into TB (A,B) values ('10',to_date('01-SEP-2012','DD-MON-RRRR'));
Insert into TB (A,B) values ('10',to_date('10-AUG-2012','DD-MON-RRRR'));
Insert into TB (A,B) values ('11',to_date('04-AUG-2012','DD-MON-RRRR'));
Insert into TB (A,B) values ('11',to_date('01-SEP-2012','DD-MON-RRRR'));
Insert into TB (A,B) values ('11',to_date('01-AUG-2012','DD-MON-RRRR'));
Insert into TB (A,B) values ('10',to_date('12-AUG-2012','DD-MON-RRRR'));
Insert into TB (A,B) values ('10',to_date('15-JUL-2012','DD-MON-RRRR'));Thanks in advance...
Ask2Learn
Edited by: Asked to Learn on Sep 1, 2012 7:55 AM
Edited by: Asked to Learn on Sep 1, 2012 8:38 AM (CHANGE DATA TYPE) SORRY

this ?
with t as
select a,b,round(count(*) over(partition by a)/2) cnt,row_number() over(order by null) rn from tb
),t1 as
select a.*,row_number() over(order by null) rn from tb a
select t1.a,t1.b from t,t1 where t1.rn=t.rn and  t1.b>t.cnt order by a;
A                    B                     
10                   4                     
10                   6                     
10                   5                     
11                   3                     
4 rows selected
Or
with t as
select a,b,round(count(*) over(partition by a)/2) cnt from tb
select a,b from t where cnt<b;

Similar Messages

  • How can i achive this result by writing SQL Query ?

    Dear Exparts,
    Here is my banner
    Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Prod
    PL/SQL Release 10.2.0.3.0 - Production
    "CORE     10.2.0.3.0     Production"
    TNS for 32-bit Windows: Version 10.2.0.3.0 - Production
    NLSRTL Version 10.2.0.3.0 - ProductionI have two table with relation. Here is the scripts of create table and insert data.
    TABLE
    CREATE TABLE TAB1
      T1_ID NUMBER(5)
    , T1_NAME VARCHAR2(100)
    ALTER TABLE TAB1 
    MODIFY (T1_ID NOT NULL);
    ALTER TABLE TAB1
    ADD CONSTRAINT TAB1_PK PRIMARY KEY
      T1_ID
    ENABLE;
    CREATE TABLE TAB2
      T2_ID NUMBER(5) NOT NULL
    , T2_T1_ID NUMBER(5)
    , T2_RV_NO VARCHAR2(20)
    , T2_RV_DATE DATE
    , T2_F1 VARCHAR2(20)
    , T2_F2 VARCHAR2(20)
    , T2_F3 VARCHAR2(20)
    , CONSTRAINT TAB2_PK PRIMARY KEY
        T2_ID
      ENABLE
    ALTER TABLE TAB2
    ADD CONSTRAINT TAB2_TAB1_FK1 FOREIGN KEY
      T2_T1_ID
    REFERENCES TAB1
      T1_ID
    ENABLE;INSERT DATA
    Insert into TAB1 (T1_ID,T1_NAME) values (1,'Test 1');
    Insert into TAB1 (T1_ID,T1_NAME) values (2,'Test 2');
    Insert into TAB2 (T2_ID,T2_T1_ID,T2_RV_NO,T2_RV_DATE,T2_F1,T2_F2,T2_F3) values (1,1,'00',to_date('01-OCT-2012','DD-MON-RRRR'),'Probation','05','Yes');
    Insert into TAB2 (T2_ID,T2_T1_ID,T2_RV_NO,T2_RV_DATE,T2_F1,T2_F2,T2_F3) values (2,1,'01',to_date('06-OCT-2012','DD-MON-RRRR'),'Confirm','06','Yes');
    Insert into TAB2 (T2_ID,T2_T1_ID,T2_RV_NO,T2_RV_DATE,T2_F1,T2_F2,T2_F3) values (3,2,'00',to_date('02-OCT-2012','DD-MON-RRRR'),'Probation','07','No');
    Insert into TAB2 (T2_ID,T2_T1_ID,T2_RV_NO,T2_RV_DATE,T2_F1,T2_F2,T2_F3) values (4,2,'01',to_date('09-OCT-2012','DD-MON-RRRR'),'Probation','07','Yes');
    Insert into TAB2 (T2_ID,T2_T1_ID,T2_RV_NO,T2_RV_DATE,T2_F1,T2_F2,T2_F3) values (5,1,'02',to_date('10-OCT-2012','DD-MON-RRRR'),'Confirm','06','No');Now i want to produce the following reports..
    Period:      06-OCT-2012 to 09-OCT-2012
    T2_RV_DATE     T1_NAME          T2_RV_NO     Revised_Column     Previous_Value     Revised_value
    06-OCT-2012     Test 1          01          T2_F1          Probation     Confirm
                                  T2_F2          05          06
    09-OCT-2012     Test 2          01          T2_F3          No          YesI just achieve Revised_Column     Previous_Value     Revised_value for a particular name.
    Here is my code
    SELECT T2_RV_NO,T2_RV_DATE,T1_NAME,'T2_F1' Revised_Column,PREVIOUS_VALUE,REVISED_VALUE
    FROM(
    SELECT T2_RV_NO,T2_RV_DATE,T1_NAME,'T2_F1',
    LAG(T2_F1) OVER (ORDER BY T2_RV_DATE) PREVIOUS_VALUE ,T2_F1 REVISED_VALUE
    FROM TAB2,TAB1
    WHERE TAB1.T1_ID=TAB2.T2_T1_ID
    AND TAB1.T1_ID=:EMP_ID)
    WHERE NVL(PREVIOUS_VALUE,'null')<>NVL(REVISED_VALUE,'null')
    AND T2_RV_DATE BETWEEN :BEGIN_DATE AND :END_DATE
    AND T2_RV_NO<>'00'
    UNION ALL
    SELECT T2_RV_NO,T2_RV_DATE,T1_NAME,'T2_F2' Revised_Column,PREVIOUS_VALUE,REVISED_VALUE
    FROM(
    SELECT T2_RV_NO,T2_RV_DATE,T1_NAME,'T2_F2',
    LAG(T2_F2) OVER (ORDER BY T2_RV_DATE) PREVIOUS_VALUE ,T2_F2 REVISED_VALUE
    FROM TAB2,TAB1
    WHERE TAB1.T1_ID=TAB2.T2_T1_ID
    AND TAB1.T1_ID=:EMP_ID)
    WHERE NVL(PREVIOUS_VALUE,'null')<>NVL(REVISED_VALUE,'null')
    AND T2_RV_DATE BETWEEN :BEGIN_DATE AND :END_DATE
    AND T2_RV_NO<>'00'
    UNION ALL
    SELECT T2_RV_NO,T2_RV_DATE,T1_NAME,'T2_F3' Revised_Column,PREVIOUS_VALUE,REVISED_VALUE
    FROM(
    SELECT T2_RV_NO,T2_RV_DATE,T1_NAME,'T2_F3',
    LAG(T2_F3) OVER (ORDER BY T2_RV_DATE) PREVIOUS_VALUE ,T2_F3 REVISED_VALUE
    FROM TAB2,TAB1
    WHERE TAB1.T1_ID=TAB2.T2_T1_ID
    AND TAB1.T1_ID=:EMP_ID)
    WHERE NVL(PREVIOUS_VALUE,'null')<>NVL(REVISED_VALUE,'null')
    AND T2_RV_DATE BETWEEN :BEGIN_DATE AND :END_DATE
    AND T2_RV_NO<>'00'but it's not work for multiple employee id
    Thanks in advance
    Edited by: Asked to Learn on Oct 6, 2012 9:18 PM

    Asked to Learn wrote:
    thanks members. i get a solution of my own for my reporting purpos. Thanks..Well why don't you post your solution? Why not be helpful to others like yourself who might search the forum looking for answers? Don't just take, give back.
    Cheers, APC

  • How to achive this using servlet

    hi I am new to this technology... My requirement is , First I have to check whether that rebate_sku_num exists in the database or not.. If exits i need to update the row.. If now I have to insert the new row with values.. How to achive this..
    my screen contains 7 rows... in will increase.. for every submit.. i have to check with the database.. whether the rebate_sku_num exists or not.. help me out.. here is my code.. i am not sure how to format my code.. in future i will do it...
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import javax.servlet.http.HttpSession;
    import javax.servlet.SingleThreadModel;
    import javax.servlet.ServletConfig;
    import javax.servlet.ServletException;
    import java.io.IOException;
    import java.sql.ResultSet;
    import java.io.*;
    import java.util.*;
    import java.util.Date;
    import java.text.*;
    public class AddRebate extends HttpServlet implements SingleThreadModel {
    public void init(ServletConfig servletconfig) throws ServletException {
    super.init(servletconfig);
    public void doPost(HttpServletRequest httpservletrequest, HttpServletResponse httpservletresponse)
    throws ServletException, IOException {
    HttpSession session;
    session = httpservletrequest.getSession(true);
    String user_name;
    String divisionCode;
    String rebate_sku_num[];
    String selectedMonth;
    String amount[];
    String message = "";
    String Query="";
    String RebateId="";
    boolean flag = true;
    // from here
    Calendar todaysdate = new GregorianCalendar();
    SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy");
    SimpleDateFormat sdf1 = new SimpleDateFormat("MM/dd/yyyy HH:MM:SS");
    System.out.println("today's date: " + sdf.format(todaysdate.getTime()));
    String entryDate = sdf.format(todaysdate.getTime());
    String entryDate1 = sdf1.format(todaysdate.getTime());
    System.out.println("entering date is " +entryDate) ;
    System.out.println("entering date is " +entryDate1) ;
    // to here
    user_name = (String) session.getAttribute("user_name");
    divisionCode = (String) session.getAttribute("division_code");
    selectedMonth = httpservletrequest.getParameter("selectedMonth");
    rebate_sku_num = httpservletrequest.getParameterValues("rebateId");
    amount = httpservletrequest.getParameterValues("amount");
    System.out.println("AddRebate : doPost() : selectedMonth = " + selectedMonth);
    System.out.println("AddRebate : doPost() : rebate_sku_num = " + rebate_sku_num);
    System.out.println("AddRebate : doPost() : amount = " + amount);
    // from here
    flag = true;
    for (int z = 0; z < rebate_sku_num.length && flag; z++) {
    try {
    flag=false;
    String s = "select REBATE_SKU_NUM from EASMSA_REBATE_SKU_DETAILS_TB where REBATE_SKU_NUM ='" + rebate_sku_num[z] + "'";
    System.out.println("AdjustmentServlet : doGet() : checking sku validity query = " + s);
    ResultSet resultset = DatabaseConnection.executeQuery(s);
    if (resultset != null) {
    while (resultset.next()) {
    RebateId = resultset.getString("REBATE_SKU_NUM");
    flag = true;
    if ((rebate_sku_num[z] != RebateId)) {
    System.out.println("get the values" +rebate_sku_num);
    System.out.println("get the values" + RebateId);
    Query = "INSERT INTO EASMSA_REBATE_SKU_DETAILS_TB " +
    "( REBATE_SKU_NUM, REBATE_DATE, REBATE_AMT, CREATED_BY," +
    "CREATION_DATE, LAST_UPDATED_BY, LAST_UPDATE_DATE ) VALUES (" +
    "'" + rebate_sku_num[z] + "', " +
    "TO_Date( '" + "30/" + selectedMonth + "', 'dd/MM/YYYY HH:MI:SS AM'), " +
    "'" + amount[z] + "' , '" + user_name + "'" +
    ", TO_Date( '" + entryDate + "', 'MM/dd/YYYY HH:MI:SS AM')" +
    ", '" + user_name + "'," +
    " TO_Date( '" + entryDate + "', 'MM/dd/YYYY HH:MI:SS AM'))";
    System.out.println("query is executed" +Query);
    }else if ((rebate_sku_num[z] == RebateId )){
    Query = "update EASMSA_REBATE_SKU_DETAILS_TB set REBATE_AMT=" + amount[z] + " where REBATE_SKU_NUM='" + rebate_sku_num[z] + "'";
    System.out.println("query is executed for updation" +Query);
    } else {
    System.out.println("AdjustmentServlet : doGet() : checking for sku validity : resultset null");
    // message = "SKU '" + sku[z] + "' of customer '" + customer[z] + "' and location '" + location[z] + "' is not valid.";
    message = "SKU '" + rebate_sku_num[z] + "' is not valid.";
    flag = false;
    } catch (Exception exception1) {
    System.out.println("AdjustmentServlet : doGet() : exception in checking validity of SKU");
    exception1.printStackTrace();
    // message = "SKU '" + sku[z] + "' of customer '" + customer[z] + "' and location '" + location[z] + "' is not valid.";
    message = "SKU '" + rebate_sku_num[z] + "' is not valid.";
    flag = false;
    try {
    if (DatabaseConnection.executeUpdate(Query) == 0) {
    System.out.println(" AddRebate : doPost() : rollback: error in executing update query= " + Query);
    DatabaseConnection.rollBack();
    message = "Some problem in updating transactions. Please try again later.";
    flag = false;
    // break;
    } else {
    System.out.println("AddRebate : doPost() : update sucessfull");
    message = "Rebate Transactions has been updated.";
    flag = true;
    } catch (Exception ex) {
    System.out.println("AddRebate : doPost() : exception in update query");
    message = "Some problem in updating transactions. Please try again later.";
    flag = false;
    ex.printStackTrace();
    session.setAttribute("message", message);
    httpservletresponse.sendRedirect("Welcome1.jsp?s=y");
    return;

    Oh and you can give me the dukes for helping you here:
    http://forum.java.sun.com/thread.jsp?forum=45&thread=475828&tstart=0&trange=15

  • How to achive current date in report

    Hi Expeorts,
    I have below Filter in one of report. how to achive this?
    Ship Date = Current Date
    What is the meaning of this? and how to do this?
    Thanks in advance
    David
    Edited by: david Rathod on Jan 10, 2012 7:50 AM

    Hi ,
    You can achieve the same using Customer exit variable .You can use the following code .
    FORM do_user_exit       USING    i_vnam        LIKE rszglobv-vnam
                                     i_vartyp      LIKE rszglobv-vartyp
                                     i_iobjnm      LIKE rszglobv-iobjnm
                                     i_s_cob_pro   LIKE rsd_s_cob_pro
                                     i_s_rkb1d     LIKE rsr_s_rkb1d
                                     i_periv       TYPE rro01_s_rkb1f-periv
                                     i_t_var_range TYPE rrs0_t_var_range
                                     i_step        TYPE i
                            CHANGING e_t_range     TYPE rsr_t_rangesid.
      if i_step = 1.
         clear l_s_range.
         l_s_range-low = sy-datum.
         l_s_range-sign = 'I'.
         l_s_range-opt  = 'EQ'.
         append l_s_range TO e_t_range.
      endif.
    ENDFORM.   
    Hope it helps .
    Thanks
    Kamal

  • How to achive this in a single iview

    How can i create this iview/How to achive this.
    In Portal I created a Role and 2 different worksets under the role to publish BW Reports (Grouped according to the worksets)
    My requirment is when user Logins into his portal account and clicks the BW Reports Tab (Role) First screen he has to see
    Currently it is my Workset1 of which are assigned to role
    My requirment is to show them
    The screen should be divided into 2 halfs(Columns) and the Left hands side column should display our INTRANET HOME PAGE and Other hald should display a BW Report developed on Daily data Loads in Graphical Version (Web Templete is already developed)
    Please update me how to achive this
    Thanks

    Hi Thruna,
    Thanks for the update....
    few Queries
    Create a page with 2 column layout.
    Is it possible for me to create a page with 2 Columns and the Right hand column is divided in to parts
    Open the page in edit mode and select Intranet Home Page iview, right click then select "Add iview to the page" with Delta.
    If i Right click the iview and select assign to page...how can i make a setting to display that iview(Intranet Home page) on Left Hand side
    Thanks in advance

  • How to achive this report.

    Hi,
    Scenario : Some raw materials qty are moving to a series of various machines in work in poress .Here some of materials are rejected Qty by machines and let say xyz reason.
    In OBI,If i pull all required columns into report all columns are pulling correct information expect machines.
    Machine column diplaying all used machines name.. but my requirement is only rejected machines and rejected qty for particular machine should be display in report.
    How to achive this.Kindly let me . Thank you.

    867932 wrote:
    Hi,
    Scenario : Some raw materials qty are moving to a series of various machines in work in poress .Here some of materials are rejected Qty by machines and let say xyz reason.
    In OBI,If i pull all required columns into report all columns are pulling correct information expect machines.
    Machine column diplaying all used machines name.. but my requirement is only rejected machines and rejected qty for particular machine should be display in report.
    How to achive this.Kindly let me . Thank you.Please take the time to explain in more detail - your post is not very precise and you dont describe your data model.
    As a guess, I would start with a filter : rejected Qty > 0 so you only get machines which have had a rejection, compared to "Machine column diplaying all used machines name".
    Hope this helps!
    Alastair

  • HT4847 How i take an old back form my old iphone to my new iphone?!when i acces icloud from my phone and go to manage storage i have 4 back up for diferent phone how can acces this data?!

    How i take an old back form my old iphone to my new iphone?!when i acces icloud from my phone and go to manage storage i have 4 back up for diferent phone how can acces this data?!

    Thanks very much!
    Although I had to add everything again to the playlist, at least I can just copy it over in future!

  • How to set this DATS parameter

    Hi Pros,
            I am calling function 'HR_FORMS_TIM_GET_B2_RESULTS' in the program , its input parameter is BEGDA, I transfer a date variable to BEGDA, but does not work. can not get any data. but if I run this function in SE37, I input date '20140807', successfully get result.  please tell me how to set this DATS parameter?

    Hi,
    You might be passing the date in '12.12.2014' or '12/12/2014' format. Please
    use the function module 'CONVERSION_EXIT_BEGDA_INPUT' to convert the date
    to internal format and then pass it to the function module.
    Thanks

  • How to print this date format: eg. 14-Aug-2002 01:26:36 PM?

    Can anyone tell me exactly how to print this format?

    This is how we can produce the output you specified.
    import java.util.*;
    import java.text.*;
    //14-Aug-2002 01:26:36 PM?
    class Test
         public static void main(String args[])
              //Date b=new Date();
              //System.out.println(b.toString());
              // Format the current time.
              SimpleDateFormat formatter = new SimpleDateFormat ("dd-MMM-yyyy ' ' hh:mm:ss a");
              Date currentTime_1 = new Date();
              String dateString = formatter.format(currentTime_1);
              System.out.println(dateString);
    }//end of Test.

  • How to achive this scenario

    Hi,
    We have report which contains many Financial products in product column.Some of product need to calculate by based on end user selection in terms of % in dashboard prompts.
    Example: If end user select or enter 10 in prompt then only Loan items has to calculate and need produce new row as Loan commitment 10%.
    I try by using calculated items but it not allowing to use presentation variable.How achive this.kindly let me know.
    EX:Base Report                                
    Financial Product
    Amount
    Credit Cards
    1300
    Deposit
    3000
    Shareholders' Fund
    2500
    Loans
    1000
    Expected Report:
    Financial Product
    Amount
    Credit Cards
    1300
    Deposit
    3000
    Shareholders' Fund
    2500
    Loans
    1000
    Loan commitment 10 %
    10

    I got answer for this question
    Thanks

  • How to optimize this sql by writing MINUS function.

    Hi all,
    how to optimize the sql by writing MINUS function.
    these are my tables
    1. CREATE TABLE POSTPAID
    RECORD VARCHAR2(2000 BYTE),
    FLAG NUMBER
    Record format:
    Mobile no in 1:10 of that length
    2. CREATE TABLE SUBSCRIBER
    PHONE_NO VARCHAR2(10 BYTE)
    My requirement is following sql need write using ‘minus’ as this one is very slow
    select record record from POSTPAID where substr(record,9,10) NOT in (select PHONE_NO from SUBSCRIBER)
    Thanks

    Why are you very particular about using "MINUS". You can optimize the sql by using "NOT EXISTS" instead of "NOT IN" as below:
    SELECT RECORD FROM POSTPAID A WHERE NOT EXISTS (SELECT 1 FROM SUBSCRIBER B WHERE SUBSTR(A.RECORD,9,10) = B.PHONE_NO)

  • Particle effect -how to achieve this kind of effect exactly

    Hello   please help me to achieve this type of flickering particle effect.  how to achieve this in After effect  which is shown at 0.8 sec to 0.11  in the attached link video. http://www.istockphoto.com/stock-video-2682258-hearts.php

    I can't give you the exact settings but you could use Trapcode Particular with a custom particle or CC Particle world. Just turn gravity to 0 and set up a custom particle.
    Your particle layer will be behind the spinning hearts layer. This should get you going in the right direction.

  • How to Achieve this Data Load into Cube

    Hi Experts,
    Could you please update me on how to achieve this
    I got a History data (25-35 Million Records) for about 8 years to be loaded to BW.
    What is the best approach to be followed
    1) Load everything into one cube and create aggregates or
    2) Create 4 different cubes (with same data model) and load load 2 years of data into each cune (2Years * 4 Cubes = 8 Years Data) and develop a multicube on top of 4 cubes
    If so how can i load data into respective cubes
    Ex: Lets assure i got data from 31.12.2007 to 01.01.2000 which is 8 years of data
    Now i created 4 Cubes--C1,C2,C3,C4 & C5
    How can i specifically
    load data from 01.01.2000 to 31.12.2001 (2 Years) to C1
    load data from 01.01.2002 to 31.12.2003 (2 Years) to C2
    load data from 01.01.2004 to 31.12.2005 (2 Years) to C3
    load data from 01.01.2006 to 31.12.2007 (2 Years) to C4
    load data from 01.01.2008 to 31.12.2010 (2 Years) to C5 (Currently Loading)
    Please advise the best approach to be followed and why
    Thanks

    If you already have the cube C5 being loaded and the reports are based on this cube, then if you donot want to create additional reports, you can go ahead and load the history data into this cube C5.
    What is your sourcesystem and datasource?. Are there selection conditions (in your infopackage) available to specify the selections? If so, you can go ahead and do full loads to the current cube.
    For query performance, you can create aggregates on this cube based on the fiscal period / month / year ( whichever infoobject is used in the reports)
    If your reports are not based on timeperiod, then multicube query will work as parrallelized sub queries and so there will be 4 dialog processes occupied on your BW system everytime the query is hit.
    Also any changes that you want to make in cube will have to be copied to all cubes, so maintenance may be a question.
    If there are enough justification, then approach 2 can be taken up

  • How to model this data

    In the sample data below, there are rows that contain header names, followed by a row with the data.
    The problem is that some of the "header" column values change.  They represent "sizes" boxes.
    Name | BoxType | Color | Qty | 45 | 11 | 13.5
    Compx | F | Red | 32 | 1 | 0 | 34
    Name | BoxType | Color | Qty | 75 | 11 | 12.5
    QuickMartZ | G | Blue | 68 | 13 | 7 | 77
    Name | BoxType | Color | Qty | 75 | 11 | 45
    QuickMartZ | F | Blue | 22 | 17 | 72 | 12
    How could I model this data or re-shape it into a schema such as
    Table
    =========
    AccountName
    BoxType
    Color
    Qty
    Size
    Ultimately I need to be able to extract a "rolled up" count of the boxes by size and their quantity
    Something like this
    AccountName
    BoxType
    Color
    Qty_Size1
    Qty_Size2
    Qty_Size3
    Qty_Size4
    Qty_Size5
    Qty_SizeN...

    Without some value which links the two rows together (other than the order of rows how do we know the box in the line above Compx belongs to it?) I don't think this is going to be possible as a set based solution.
    You could use a cursor to move through the rows RBAR:
    DECLARE @table TABLE (name VARCHAR(20), boxType VARCHAR(20), color VARCHAR(20), qty VARCHAR(4), col1 INT, col2 INT, col3 FLOAT)
    INSERT INTO @table (name, boxType, color, qty, col1, col2, col3)
    VALUES
    ('Name', 'BoxType', 'Color', 'Qty', 45, 11, 13.5),
    ('Compx', 'F', 'Red', '32', 1, 0 , 34),
    ('Name', 'BoxType', 'Color', 'Qty', 75, 11, 12.5),
    ('QuickMartZ', 'G', 'Blue', '68', 13, 7 , 77),
    ('Name', 'BoxType', 'Color', 'Qty', 75, 11, 45),
    ('QuickMartZ', 'F', 'Blue', '22', 17, 72, 12)
    DECLARE @name VARCHAR(20), @boxType VARCHAR(20), @color VARCHAR(20), @qty VARCHAR(4), @col1 INT, @col2 INT, @col3 FLOAT,
    @pname VARCHAR(20), @pboxType VARCHAR(20), @pcolor VARCHAR(20), @pqty VARCHAR(4), @pcol1 INT, @pcol2 INT, @pcol3 FLOAT
    DECLARE @products TABLE (name VARCHAR(20), boxType VARCHAR(20), color VARCHAR(20), qty VARCHAR(4), size1 FLOAT, size2 FLOAT, size3 FLOAT)
    DECLARE @boxes TABLE (name VARCHAR(20), boxType VARCHAR(20), size1 FLOAT, size2 FLOAT, size3 FLOAT)
    DECLARE c1 CURSOR
    FOR SELECT *
    FROM @table
    OPEN c1
    FETCH c1 INTO @name, @boxType, @color, @qty, @col1, @col2, @col3
    WHILE @@FETCH_STATUS <> -1
    BEGIN
    IF @name = 'name'
    BEGIN
    SET @pname = @name
    SET @pboxType = @boxType
    SET @pcolor = @color
    SET @pqty = @qty
    SET @pcol1 = @col1
    SET @pcol2 = @col2
    SET @pcol3 = @col3
    END
    IF @name <> 'name'
    BEGIN
    INSERT INTO @products (name, boxType, color, qty, size1, size2, size3) VALUES (@name, @boxType, @color, @qty, @col1, @col2, @col3)
    INSERT INTO @boxes (name, boxType, size1, size2, size3) VALUES (@name, @boxType, @pcol1, @pcol2, @pcol3)
    END
    FETCH c1 INTO @name, @boxType, @color, @qty, @col1, @col2, @col3
    END
    CLOSE c1
    DEALLOCATE c1
    SELECT *
    FROM @products
    SELECT *
    FROM @boxes

  • How to solve this Data Configuration issue with error message ORA: 01017

    Bad public user name or password. ORA-01017: invalid username/password; logon denied
    How to solve this?

    I'm using JCreator jdk1.5.0_7.But i don't know how
    to use command prompt. When i execute my program, the
    command prompt showed
    Exception in thread "main"
    java.lang.NoClassDefFoundError: StringManipulation
    Press any key to continue...So you managed to compile your code since now you are running it. This error means that the class StringManipulation was not found. Usually an indicator that your classpath is incorrect.
    What did you do to generate this error? That is, how did you execute your program?
    [edit] if you did not compile your code then there is no class file StringManipulation.class and this error will appear.

Maybe you are looking for

  • Cross-dissolve from white frame to adjustment layer no longer works in CC 2014

    Windows 7, Premiere Pro CC 2014 I have a video clip in a nested sequence on V1 and an adjustment layer on V2. I want to dissolve from a white frame to the clip using the adjustment layer. In PP CC (not 2014) this was simple: Starting with a white PNG

  • Where can I purchase a new LCD for my ZEN

    A friend broke my ZEN screen (8GB if it matters) and I told her I would try to fix it instead of buy a new one... I have the unit apart and the LCD does just plug in... I tried online to match the part # with no luck.... Part # HA070820E0 Anyone?

  • ERP 2005 application server on Solaris 10 T2000 ABAP & Java stacks

    We are interested to know if there are any companies running Sun T2000 servers, Solaris 10, in the application layer for both ABAP & Java stacks.  If so, how are they performing? Regards, Cheryl Siebert.

  • Active Directory Structure Questions

    I recently started working for a company that offers cloud services for our clients where we host our software as a service and we also migrate any other applications the client is using onto the servers that we host for them. My concern is that ever

  • Slow launch and intermittent freezing in Windows 8.1

    Been trolling through the threads and cannot find a solution. I've also tried the QTMovieWin.dll solution but no change. I've also uninstalled, then went back and deleted all reminants of iTunes related files (incl. Bonjour, iCloud, etc), then re sta