SQL: group by some data

Hi expert
I have a table with the column FIRST and LAST as per example
>
FIRST;LAST
FIRST1;LAST1
FIRST2;LAST2
FIRST3;LAST3
FIRST4;LAST4
FIRST5;LAST5
FIRST6;LAST6
FIRST7;LAST7
FIRST8;LAST8
FIRST9;LAST9
FIRST10;LAST10
FIRST11;LAST11
FIRST12;LAST12
>
I'd like to do an sql that create the value of column ID with a "group by" by 5 records. For example from 1 to 5 the ID will be 1, from 6 to 10 the ID will be 2. Below the result that I'd to do
>
ID;FIRST;LAST
1;FIRST1;LAST1
1;FIRST2;LAST2
1;FIRST3;LAST3
1;FIRST4;LAST4
1;FIRST5;LAST5
2;FIRST6;LAST6
2;FIRST7;LAST7
2;FIRST8;LAST8
2;FIRST9;LAST9
2;FIRST10;LAST10
;FIRST11;LAST11
;FIRST12;LAST12
>
The last 2 records will not a ID because the count of them is less of 5.
Many thanks for any idea.
Cheers,
Lain

Or like this...
SQL> ed
Wrote file afiedt.buf
  1  with t as (select 'FIRST1' as FIRST, 'LAST1' as LAST from dual union all
  2             select 'FIRST2', 'LAST2' from dual union all
  3             select 'FIRST3', 'LAST3' from dual union all
  4             select 'FIRST4', 'LAST4' from dual union all
  5             select 'FIRST5', 'LAST5' from dual union all
  6             select 'FIRST6', 'LAST6' from dual union all
  7             select 'FIRST7', 'LAST7' from dual union all
  8             select 'FIRST8', 'LAST8' from dual union all
  9             select 'FIRST9', 'LAST9' from dual union all
10             select 'FIRST10', 'LAST10' from dual union all
11             select 'FIRST11', 'LAST11' from dual union all
12             select 'FIRST12', 'LAST12' from dual)
13  --
14  -- End Of Test Data
15  --
16  select decode(count(*) over (partition by id), 5, id) as id
17        ,first
18        ,last
19  from (
20        select floor((row_number() over (order by ord)-1)/5)+1 as id
21              ,first
22              ,last
23              ,ord
24        from (select first, last, to_number(replace(first,'FIRST')) ord from t)
25       )
26* order by ord
SQL> /
        ID FIRST   LAST
         1 FIRST1  LAST1
         1 FIRST2  LAST2
         1 FIRST3  LAST3
         1 FIRST4  LAST4
         1 FIRST5  LAST5
         2 FIRST6  LAST6
         2 FIRST7  LAST7
         2 FIRST8  LAST8
         2 FIRST9  LAST9
         2 FIRST10 LAST10
           FIRST11 LAST11
           FIRST12 LAST12
12 rows selected.
SQL>Though, I assume your data is not "FIRST1", "FIRST2" etc., so the ordering of the data will have to be done according to what data you have. In my solution I've stripped out the word "FIRST" to allow it to be ordered on the numeric part of the data. I assume you've got some other data there to allow you to determine the order though.

Similar Messages

  • Put some data form the databse of SQL Server into SAP and auto general PR?

    Dear all,
            Can you tell me how I can put some data from the databse of SQL Server into SAP and auto general PR?
    Best regards,
    Merryzhang
    Edited by: merry zhang on Feb 4, 2009 9:10 AM

    Hi Zhang,
    If i have understood your question properly, I guess you wanted to create Purchase Requistion automatically right?
    Then you have lots of option simpilest one would be create a couple of Z table with all the fields that you require for header and Item.
    create a Program and use BAPI function module to create the PR by reading the values from those Z tables. after creation delete the contents from the table. Schedule this program in Background periodically like everyday or weekly once however you would like it to be. So once the table has contents in it and when the program runs it will create the PR's (Purchase Requisition).
    You can also use a workflow with the Z table. Once the Z table is filled you can trigger a workflow based on the Table change. I'm not sure like how to do it but I nkow that this process can also be used.
    Hope this might have thrown some light upon.
    Thanks,
    Prashanth

  • Grouping with 2 date in sql server

    totle_count
             dt
             name   
    program_id
    1
      1/3/2015
      Tea
    14
    1
      1/5/2015
      Tea
    14
    1
      1/6/2015
      Lunch
    13
    17
    1/6/2015
      Tea
    14
    2
    1/9/2015
      Breakfast
    1008
    39
    1/10/2015
      Breakfast
    1008
    4
    1/19/2015
      Breakfast
    1008
    1
    1/19/2015
      Dinner
    1009
    3
    1/21/2015
       Tea
    14
    totle_count
              dt
    name
    program_id
    1
       1/6/2015 and 1/8/2015
      Lunch
    13
    2
       1/3/2015 and 1/5/2015
      Tea
    14
    17
       1/6/2015 and 1/9/2015
      Tea
    14
    3
       1/21/2015 and 1/23/2015
      Tea
    14
    41  
    1/9/2015 and 1/11/2015
     Breakfast
    1008
    4
       1/18/2015 and 1/20/2015
     Breakfast
    1008
    1
       1/18/2015 and1/20/2015
    Dinner
    1009
    Here is 2 table, 1st is my row table, and I want to group with 2 date.
    Here is 3 days difference. and sum of value is coming.
    2nt table is my expectation table.
    Plz help me for this problem.
    Thanks
    Samir

    I am doing 3 days grouping here
    "dt" is name of date column
    if "dt" column has '1/19/2015' then next in group it will come in "1/18/2015 and1/20/2015"
    any date of 18 or 19 0r 20 it will come in "1/18/2015 and1/20/2015"
    and counting will add between 3 date
    Sorry your posted output is not as per above rule
    How did row for  1/6/2015 and 1/9/2015 got included then. If you group by 3 days you wont get
    this row as 6-9 is 4 days not 3 days
    Please Mark This As Answer if it solved your issue
    Please Vote This As Helpful if it helps to solve your issue
    Visakh
    My Wiki User Page
    My MSDN Page
    My Personal Blog
    My Facebook Page

  • Sql grouping and summing impossible?

    I want to create an sql query to sum up some data but i'm starting to think it is impossible with sql alone. The data i have are of the following form :
    TRAN_DT     TRAN_RS     DEBT     CRED
    10-Jan     701     100     0
    20-Jan     701     150     0
    21-Jan     701     250     0
    22-Jan     705     0     500
    23-Jan     571     100     0
    24-Jan     571     50     0
    25-Jan     701     50     0
    26-Jan     701     20     0
    27-Jan     705     0     300The data are ordered by TRAN_DT and then by TRAN_RS. Tha grouping and summing of data based on tran_rs but only when it changes. So in the table above i do not want to see all 3 first recods but only one with value DEBT the sum of those 3 i.e. 100+150+250=500. So the above table after grouping would be like the one below:
    TRAN_DT     TRAN_RS     DEBT     CRED
    21-Jan     701     500     0
    22-Jan     705     0     500
    24-Jan     571     150     0
    26-Jan     701     70     0
    27-Jan     705     0     300The TRAN_DT is the last value of the summed records. I undestand that the tran_dt may not be selectable. What i have tried so far is the following query:
    select tran_dt,
             tran_rs,
             sum(debt)over(partition by tran_rs order by tran_dt rows unbounded preceding),
             sum(cred)over(partition by tran_rs order by tran_dt rows unbounded preceding) from that_tableIs this even possible with sql alone, any thoughts?
    The report i am trying to create in BI Publisher.Maybe it is possible to group the data in the template and ask my question there?

    915218 wrote:
    Is this even possible with sql alone, any thoughts?It sure is...
    WITH that_table as (select to_date('10/01/2012', 'dd/mm/yyyy') tran_dt, 701 tran_rs, 100 debt, 0 cred from dual union all
                         select to_date('20/01/2012', 'dd/mm/yyyy') tran_dt, 701 tran_rs, 150 debt, 0 cred from dual union all
                         select to_date('21/01/2012', 'dd/mm/yyyy') tran_dt, 701 tran_rs, 250 debt, 0 cred from dual union all
                         select to_date('22/01/2012', 'dd/mm/yyyy') tran_dt, 705 tran_rs, 0 debt, 500 cred from dual union all
                         select to_date('23/01/2012', 'dd/mm/yyyy') tran_dt, 571 tran_rs, 100 debt, 0 cred from dual union all
                         select to_date('24/01/2012', 'dd/mm/yyyy') tran_dt, 571 tran_rs, 50 debt, 0 cred from dual union all
                         select to_date('25/01/2012', 'dd/mm/yyyy') tran_dt, 701 tran_rs, 50 debt, 0 cred from dual union all
                         select to_date('26/01/2012', 'dd/mm/yyyy') tran_dt, 701 tran_rs, 20 debt, 0 cred from dual union all
                         select to_date('27/01/2012', 'dd/mm/yyyy') tran_dt, 705 tran_rs, 0 debt, 300 cred from dual)
    , brk AS (
    SELECT     tran_dt,
            tran_rs,
         debt,
         cred,
            CASE WHEN Nvl (Lag (tran_rs) OVER (ORDER BY tran_dt, tran_rs), 0) != tran_rs THEN tran_rs || tran_dt END brk_tran_rs
      FROM that_table
    ), grp AS (
    SELECT     tran_dt,
            tran_rs,
             debt,
             cred,
            Last_Value (brk_tran_rs IGNORE NULLS) OVER  (ORDER BY tran_dt, tran_rs) grp_tran_rs
      FROM brk
    SELECT     Max (tran_dt),
            Max (tran_rs),
             Sum (debt),
             Sum (cred)
      FROM grp
    GROUP BY grp_tran_rs
    ORDER BY 1, 2
    Boneist
    MAX(TRAN_    TRAN_RS       DEBT       CRED
    21-JAN-12        701        500          0
    22-JAN-12        705          0        500
    24-JAN-12        571        150          0
    26-JAN-12        701         70          0
    27-JAN-12        705          0        300
    Me
    MAX(TRAN_ MAX(TRAN_RS)  SUM(DEBT)  SUM(CRED)
    21-JAN-12          701        500          0
    22-JAN-12          705          0        500
    24-JAN-12          571        150          0
    26-JAN-12          701         70          0
    27-JAN-12          705          0        300Edited by: BrendanP on 17-Feb-2012 04:05
    Test data courtesy of Boneist, and fixed bug.
    Edited by: BrendanP on 17-Feb-2012 04:29

  • Sum of LineCount Including Groups and Detail Data On Each Page Used To Generate New Page If TotalPageLineCount 28

    Post Author: tadj188#
    CA Forum: Formula
    Needed: Sum of LineCount Including Groups and Detail Data On Each Page Used To Generate New Page If TotalPageLineCount > 28
    Background:
    1) Report SQL is created with unions to have detail lines continue on a page, until it reaches page footer or report footer, rather than using  subreports.    A subreport report is now essentially a group1a, group1b, etc. (containing column headers and other data within the the report    with their respective detail lines).  I had multiple subreports and each subreport became one union.
    Created and tested, already:
    1) I have calculated @TotalLineForEachOfTheSameGroup, now I need to sum of the individual same group totals to get the total line count on a page.
    Issue:
    1) I need this to create break on a certain line before, it dribbles in to a pre-printed area.
    Other Ideas Appreciated:
    1) Groups/detail lines break inconveniently(dribble) into the pre-printed area, looking for alternatives for above situation.
    Thank you.
    Tadj

    export all image of each page try like this
    var myDoc = app.activeDocument;
    var myFolder = myDoc.filePath;
    var myImage = myDoc.allGraphics;
    for (var i=0; myImage.length>i; i++){
        app.select(myImage[i]);
        var MyImageNmae  = myImage[i].itemLink.name;
        app.jpegExportPreferences.jpegQuality = JPEGOptionsQuality.high;
        app.jpegExportPreferences.exportResolution = 300;
           app.selection[0].exportFile(ExportFormat.JPG, File(myFolder+"/"+MyImageNmae+".JPEG"), false);
        alert(myImage[i].itemLink.name)

  • Apex 4.0 - Can see view data in SQL*Plus but no data in Object Browser

    Hi There,
    I have just started using Apex 4.o and migrated some apps. I have an issue with a report, but see the same issue with Object browser, which is easier to describe.
    I have a view:
    create or replace view V_PLJ_USERDEF_CODES (
             CODE_SET_ID,
             CODE_SET_CODE,
             CODE_SET_DESC,
             CODE_ID,
             CODE_SYS_CODE,
             CODE_VALUE,
             CODE_DESC,
             DISPLAY_SEQ,
             DISPLAY_FLAG,
             LANGUAGE_CODE) as
      select CS.CODE_SET_ID,
             CS.CODE_SET_CODE,
             CS.CODE_SET_DESC,
             C.CODE_ID,
             C.CODE_SYS_CODE,
             C.CODE_VALUE,
             C.CODE_DESC,
             C.DISPLAY_SEQ,
             C.DISPLAY_FLAG,
             C.LANGUAGE_CODE
        from PLJ_CODES C,
             PLJ_CODE_SETS CS
       where C.CODE_SET_ID         = CS.CODE_SET_ID
         and CS.CODE_SET_TYPE_CODE = SYS_CONTEXT('PLJUMPSTART','C_USERDEF_CODE_SET');This returns data in SQL*Plus, but no data in Object Browser OR report region based on this view.
    Workspace parses in the same schema as tested in SQL*Plus.
    If, in report, I swap out view, and use underlying table - no problem.
    Any ideas -
    thanks
    P

    Hi all,
    Thanks for getting back so promptly.
    It just seems weird to me, as tables are just fine, but not views.
    In the underlying schema:
    SQL> sho user
    USER is "ICSREPORTING"
    SQL> select count(*) from plj_codes;
      COUNT(*)
           107
    SQL> select count(*) from v_plj_userdef_codes;
      COUNT(*)
            29And in the APEX schema
    SQL> sho user
    USER is "APEX_040000"
    SQL> select count(*) from icsreporting.plj_codes;
    select count(*) from icsreporting.plj_codes
    ERROR at line 1:
    ORA-00942: table or view does not exist
    SQL> select count(*) from icsreporting.v_plj_userdef_codes;
    select count(*) from icsreporting.v_plj_userdef_codes
    ERROR at line 1:
    ORA-00942: table or view does not exist
    SQL>However, in SQL browser, I can see the data in PLJ_CODES but in V_PLJ_USERDEF_CODES, just the message "This view has no data". Indeed, it is like this for all views.
    I even explicitly granted access to APEX_040000 but no good.
    In fact, I would like to know more about how Apex gets access to do DML against the underlying parsing schema(s).
    This is a little frustrating though. It worked just fine in lots of apps in version 2.1 to 3.2
    Am I missing something
    paul
    p.s I knew there would be a question about the context, but I had already checked that. :)
    Edited by: PJ on Nov 19, 2010 4:09 AM

  • How to export some data from the tables of an owner with integrity?

    Hi to all,
    How to export some data from the tables of an owner with integrity?
    I want to bring some data from all tables in a single owner of the production database for development environment.
    My initial requirements are: seeking information on company code (emp), contract status (status) and / or effective date of contract settlement (dt_liq_efetiva) - a small amount of data to developers.
    These three fields are present in the main system table (the table of contracts). Then I thought about ...
    - create a temporary table from the query results table to contract;
    - and then use this temporary table as a reference to fetch the data in other tables of the owner while maintaining integrity. But how? I have not found the answer, because: what to do when not there is the possibility of a join between the contract and any other table?
    I am considering the possibility of consulting the names of tables, foreign keys and columns above, and create dynamic SQL. Conceptually, something like:
    select r.constraint_name "FK name",
    r.table_name "FK table",
    r.column_name "FK column",
    up.constraint_name "Referencing name",
    up.table_name "Referencing table",
    up.column_name "Referencing column"
    from all_cons_columns up
    join all_cons_columns r
    using (owner, position), (select r.owner,
    r.constraint_name fk,
    r.table_name table_fk,
    r.r_constraint_name r,
    up.table_name table_r
    from all_constraints up, all_constraints r
    where r.r_owner = up.owner
    and r.r_constraint_name = up.constraint_name
    and up.constraint_type in ('P', 'U')
    and r.constraint_type = 'R'
    and r.owner = 'OWNERNAME') aux
    where r.constraint_name = aux.fk
    and r.table_name = aux.table_fk
    and up.constraint_name = aux.r
    and up.table_name = aux.table_r;
    -- + Dynamic SQL
    If anyone has any suggestions and / or reuse code to me thank you very much!
    After resolving this standoff intend to mount the inserts in utl_file by a table and create another program to read and play in the development environment.
    Thinking...
    Let's Share!
    My thanks in advance,
    Philips

    Thanks, Peter.
    Well, I am working with release 9.2.0.8.0. But the planning is migrate to 10g this year. So my questions are:
    With Data Pump can export data just from tables owned for me (SCHEMAS = MYOWNER) parameterizing the volume of data (SAMPLE) and filters to table (QUERY), right? But parameterizing a contract table QUERY = "WHERE status NOT IN (2,6) ORDER BY contract ":
    1º- the Data Pump automatically searches for related data in other tables in the owner? ex. parcel table has X records related (fk) with Y contracts not in (2,6): X * SAMPLE records will be randomly exported?
    2º- for the tables without relation (fk) and which are within the owner (MYOWNER) the data is exported only based on the parameter SAMPLE?
    Once again, thank you,
    Philips
    Reading Oracle Docs...

  • Sql loader and bulk data

    hi,
    I want to insert 100,000 records daily in a table for the first month and then in next month these records are going to be replaced by new updated records.
    there might be few addition and deletion in the previous records also.
    actually its consumer data so there might be few consumer who have withdrawn the utility and there will be some more consumer added in the database.
    but almost 99% of the previous month data have to be updated/replaced with the fresh month data.
    For instance, what i have in my mind is that i will use sql loader to load data for the first month and then i will delete the previous data using sqlPlus and load the fresh month data using sql loader again.
    1. Is this ok ? or there is some better solution to this.
    2. I have heard of external files, are they feasible in my scenario?
    3. I have planned that i will make scripts for sqlPlus and Loader and use them in batch files. (OS windows 2003 server, Oracle 9i database). is there some better choice to make all the procedure automatic?
    looking for your suggestions
    nadeem ameer

    I would suggest u use External tables since its more flexible then
    sqlloader & is a better option.
    For using external tables
    1)u will have to create a directory first
    2)Generally creation od directory is done by sys,hence after creating the directory
    privileges read & write to be provided to user .
    3)Creation of external tables.
    4) Now use the table as a normal table to insert ,update delete in
    ur table.
    U can get more information from
    http://www.oracle-base.com/articles/9i/SQLNewFeatures9i.php#ExternalTables
    Create Directory <directory_name> as <Directory path where file be present>
    Grant read,write on directory <directory_name> to <username>
    CREATE TABLE <table_name>
    (<column names>)
    ORGANIZATION EXTERNAL
    TYPE ORACLE_LOADER
    DEFAULT DIRECTORY ,directory_name>
    ACCESS PARAMETERS
    RECORDS DELIMITED BY NEWLINE
    FIELDS TERMINATED BY ','
    LOCATION (<filename>)
    PARALLEL 5
    REJECT LIMIT 200;
    Hope this helps.

  • Java.sql.SQLException:ORA-01801:date format is too long for internal buffer

    Hi,
    I am getting the following exception when i trying to insert data in to a table through a stored procedure.
    oracle.apps.fnd.framework.OAException: java.sql.SQLException: ORA-01801: date format is too long for internal buffer
    when execute this stored procedure from ana anonymous block , it gets executed successfully, but i use a OracleCallableStatement to execute the procedure i am getting this error.
    Please let me know how to resolve this error.
    Is this error something to do with the Database Configuration ?
    Thanks & Regards
    Meenal

    I don't know if this will help, but we were getting this error in several of the standard OA framework pages and after much pain and aggravation it was determined that visiting the Sourcing Home Page was changing the timezone. For most pages this just changed the timezone that dates were displayed in, but some had this ORA-01801 error and some others had an ORA-01830 error (date format picture ends before converting entire input string). Unfortunately, if you are not using Sourcing at your site, this probably won't help, but if you are, have a look at patch # 4519817.
    Note that to get the same error, try the following query (I got this error in 9.2.0.5 and 10.1.0.3):
    select to_date('10-Mar-2006', 'DD-Mon-YYYY________________________________________________HH24:MI:SS') from dual;
    It appears that you can't have a date format that is longer than 68 characters.

  • Count(*) with group by max(date)

    SQL> select xdesc,xcust,xdate from coba1 order by xdesc,xcust,xdate;
    XDESC XCUST XDATE
    RUB-A 11026 01-JAN-06
    RUB-A 11026 05-JAN-06
    RUB-A 11026 08-JAN-06
    RUB-A 11027 10-JAN-06
    RUB-B 11026 02-JAN-06
    RUB-B 11026 08-JAN-06
    RUB-B 11026 09-JAN-06
    RUB-C 11027 08-JAN-06
    I want to make sql that result :
    XDESC     COUNT(*)
    RUB-A     2
    RUB-B 1
    RUB-C 1
    Criteria : GROUPING: XDESC XCUST AND MAX(DATE)
    bellow mark *** that was selected in count.
    XDESC XCUST XDATE
    RUB-A 11026 01-JAN-06
    RUB-A 11026 05-JAN-06
    RUB-A 11026 08-JAN-06 ***
    RUB-A 11027 10-JAN-06 ***
    ---------------------------------------------------------COUNT RUB-A = 2
    RUB-B 11026 02-JAN-06
    RUB-B 11026 08-JAN-06
    RUB-B 11026 09-JAN-06 ***
    ---------------------------------------------------------COUNT RUB-B = 1
    RUB-C 11027 08-JAN-06 ***
    --------------------------------------------------------COUNT RUB-C = 1
    Can Anybody help ?
    I tried :
    select xdesc,max(xdate),count(max(xdate)) from coba1 group by xdesc
    ERROR at line 1:
    ORA-00937: not a single-group group function
    Thank

    This one is duplicate. see the following link
    Count(*) with group by max(date)
    Thanks

  • Java.sql.SQLException: No more data to read from socket

    Hello,
    we're now facing some strange problem which is probably caused by some malfunctioned connections being present in connection pool. The MGP process is failing for some clients with following error message. During the MGP process, some users are processed without any problems and some encounter this exception. I tried to restart the DB and both OL servers (we have 2 OL servers, on one of them is running MGP), but it didn't help.
    Some time before I restarted the servers, we were also occasionally facing "Server connections exceeded" error message, but I don't think this is relevant...
    We're using 10gR2 OL servers and 10gR2 RDBMS.
    Any ideas what could be wrong?
    <pre>
    Applied Record     Counts:
    Insert Count     = 0
    Update Count     = 0
    Delete Count     = 0
    Composed PubItems
    (<PubItem Name>, <Duration     in Milli Seconds>):
    JPOCZ_C$ALL_CLIENTS,16
    JPOCZ_PA_STATESTOCKSUM,1484
    JPOCZ_PA_MEMOS,31
    JPOCZ_TASKMOTYPES,47
    JPOCZ_PA_VISITDETAILS,16
    JPOCZ_PA_STATESTOCK,859
    JPOCZ_DISTRIBS,47
    JPOCZ_ITEMPRICING,438
    Compose Error:
    java.sql.SQLException: No more data to read from socket
         at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:189)
         at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:231)
         at oracle.jdbc.dbaccess.DBError.check_error(DBError.java:985)
         at oracle.jdbc.ttc7.MAREngine.unmarshalUB1(MAREngine.java:746)
         at oracle.jdbc.ttc7.MAREngine.unmarshalSB1(MAREngine.java:705)
         at oracle.jdbc.ttc7.Ocommoncall.receive(Ocommoncall.java:108)
         at oracle.jdbc.ttc7.TTC7Protocol.rollback(TTC7Protocol.java:427)
         at oracle.jdbc.driver.OracleConnection.rollback(OracleConnection.java:1410)
         at oracle.lite.sync.JupConnection.rollback(Unknown Source)
         at oracle.lite.sync.MGP$MGPG.run(Unknown Source)
         at java.lang.Thread.run(Unknown Source)
    </pre>

    I'm not using localhost, but the host name. We just today notified some other network problems on this server and discovered there're 2 network cards - one of them which wasn't connected was configured for DHCP and the other one was configured properly with fixed IP address. We disabled the disconnected network card and it looks like the problems with other applications is solved so we'll se if the Mobile Server is also cured...

  • How to run recordset SQL query in FORM DATA event

    How can I run recordset SQL query in FORM DATA event upon clicking on Add button in the document?

    Hi Slamet,
    When you receive a form data event you have a class containing inside it a ObjectKeys xml info regarding the object added/modified,...
    With the objects keys you can then use the DI API method called GetByKeys to obtain the DI Object.
    There is some information about it in the SDK Help file, mainly in the "FormDataEvent" class definition:
    <i>The event provides the unique ID (BusinessObjectInfo.ObjectKey) of the modified business object. You can use the value of this property as an input parameter in the DI API DataBrowser.GetByKeys method to get a DI object.</i>
    Pay attention you don't have this information in the Before=True event of the Add as it is not yet in the database.
    Hope it helps
    Trinidad.

  • Group by with date range.

    Hi,
    I am looking for effective usage of Group by against date range.
    I have a transaction table as below.
    Date            customer_no      amount_paid
    01-Dec-13     001                  500
    02-Dec-13     001                  360
    09-Dec-13     001                  200
    02-Nov-13     001                  360
    09-Nov-13     001                  200
    02-Nov-13     001                  360
    09-Oct-13     001                  200
    02-Oct-13     001                  360
    09-Oct-13     001                  200
    02-Sep-13     001                  360
    09-Sep-13     001                  200
    ............... etc.
    I would like to see sum(amount_paid) by past date ranges 1-30 days, 31-60 days, 61-90 days.
    Below are expected results.
    Customer          Duration       amount_paid
    001                    1-30             980
    001                    31-60           450
    001                    61-90          1200
    002                    1-30             300
    002                    31-60           490
    002                    61-90           320
    003                    1-30             450
    ......................etc.
    I have to group by customer no and date range (1-30, 31-60, 61-90..etc).
    Can someone help me getting query for this.
    Thanks...
    Sreeram.

    SQL> with t
      2  as
      3  (
      4  select to_date('01-Dec-13', 'dd-Mon-rr') dt, '001' customer_no, 500 amount_paid from dual
      5    union all
      6  select to_date('02-Dec-13', 'dd-Mon-rr') dt, '001' customer_no, 360 amount_paid from dual
      7    union all
      8  select to_date('09-Dec-13', 'dd-Mon-rr') dt, '001' customer_no, 200 amount_paid from dual
      9    union all
    10  select to_date('02-Nov-13', 'dd-Mon-rr') dt, '001' customer_no, 360 amount_paid from dual
    11    union all
    12  select to_date('09-Nov-13', 'dd-Mon-rr') dt, '001' customer_no, 200 amount_paid from dual
    13    union all
    14  select to_date('02-Nov-13', 'dd-Mon-rr') dt, '001' customer_no, 360 amount_paid from dual
    15    union all
    16  select to_date('09-Oct-13', 'dd-Mon-rr') dt, '001' customer_no, 200 amount_paid from dual
    17    union all
    18  select to_date('02-Oct-13', 'dd-Mon-rr') dt, '001' customer_no, 360 amount_paid from dual
    19    union all
    20  select to_date('09-Oct-13', 'dd-Mon-rr') dt, '001' customer_no, 200 amount_paid from dual
    21    union all
    22  select to_date('02-Sep-13', 'dd-Mon-rr') dt, '001' customer_no, 360 amount_paid from dual
    23    union all
    24  select to_date('09-Sep-13', 'dd-Mon-rr') dt, '001' customer_no, 200 amount_paid from dual
    25  )
    26  select customer_no
    27       , ((grp_val - 1) * 30) + 1 start_val
    28       , grp_val * 30 end_val
    29       , sum(amount_paid) amount_paid
    30    from (
    31            select dt
    32                 , customer_no
    33                 , amount_paid
    34                 , ceil(sum(dt_interval) over(partition by customer_no order by dt)/30) grp_val
    35              from (
    36                      select dt
    37                           , customer_no
    38                           , amount_paid
    39                           , nvl(dt - lag(dt) over(partition by customer_no order by dt), 1) dt_interval
    40                        from t
    41                   )
    42         )
    43   group
    44      by customer_no
    45       , grp_val
    46   order
    47      by grp_val;
    CUS  START_VAL    END_VAL AMOUNT_PAID
    001          1         30         560
    001         31         60         760
    001         61         90         920
    001         91        120        1060
    SQL>

  • SQL Server 2005 huge data migration. Taking more than 18 hours ...

    Hi,
    We are migrating an SQL server 2005 DB to Oracle 10 g 64 bit 10.2.0.5. The source sql server DB has few tables (<10) and only few stored procedure(<5). However one table of source is very huge, it has 70 million records in it. I started the migration process; it was running till 18 hours passed away then I cancelled it. I am using SQL Developer 3.1.0.7 with online migration.
    Kindly let me know if I choose offline migration will it reduce the data move time. Is there some other tool by oracle that can migrate huge data (records in millions) quickly. Is there some configuration in SQL Developer that can catalyses the process?
    Kindly help.
    Best Regards!
    Irfan

    I tried using SQL Loader to move data. The file exported by SQL server for the transaction table is of size around 17 GB. The sql loader stopped giving error on file size limit. The error is given below:
    SQL*Loader: Release 10.2.0.5.0 - Production on Thu Mar 22 15:15:28 2012
    Copyright (c) 1982, 2007, Oracle. All rights reserved.
    SQL*Loader-510: Physical record in data file (E:/mssqldata/transaction.txt) is longer than the maximum(1048576)
    SQL*Loader-2026: the load was aborted because SQL Loader cannot continue.
    C:\Users\Administrator\Desktop\wuimig\datamove\wuimig\2012-03-22_14-20-29\WUI\dbo\control>
    Please help me out how do I move such huge data to oracle from sql server.
    Best Regards!

  • SQL remote query and data-dictionary

    Hi,
    We are considering the implementation of SAP Business One 2005. I've installed a demo version but in order for it to continue to support some business functions I need to perform a number of SQL queries against the data. Unfortunately I'm having difficulties in getting the answer from our reseller.
    Does anyone know the answers to the following question. I'd very much appreciate some help.
    1) Is there a data-dictionary document showing which tables perform which roles and the associated joins/associations.
    2) Is it 'advised' to open the SAP datasource directly to perform a SELECT query to obtain the results or should a third-party tool be used?
    3) Do I need the SDK if I want to perform direct SELECT queries or if I want to automate posting invoices to SAP? We have competent programmers in the company - I believe they use VB6 and VB.net.
    4) Is there an example if I simply wanted to query all suppliers within SAP? (e.g. SELECT NAME FROM Supplier_tbl...etc..etc)
    Any help would be very much appreciated - it's a huge application and I'm struggling a little.
    Many thanks,
    Gavin Russell.

    Gavin,
    The forum that you have posted your questions in is or questions related to the SAP Business One Integration for SAP NetWeaver.  Your questions seem to be along the line of general data access to SAP Business One.  You should typically post those types of questions in the SAP Business One Discussion Forum or the SAP Business One SDK Discussion Forum.
    As to your questions ...
    1.  The definition of the SAP Business One table schema is part of the SAP Business One SDK Help Center documentation.  You simply need to install the SAP Business One SDK Help and you will have it.  There is not a "data dictionary" other than this documentation.
    2.  Typically any direct access to SAP Business One data using SQL is discouraged as if data corruption occurs as a result of it, the environment would not then be supported by SAP.
    3.  If you want to push data into SAP Business One, as stated, direct access to the Business One database is forbidden.  You would use the SAP Business One SDK for this.
    4.  You can use the SAP Business One Query Manager/Wizard in the SAP Business One product which in essence is performing SQL type SELECTS for data on Business One tables.
    HTH,
    Eddy

Maybe you are looking for

  • Obtaining values from other programs

    I seen where you can use Spy ++ to get values from other running programs, how do you do it? I found the values un Spy ++ from the window, so where from I go from here? Regards, Carter Humphreys

  • Error in setting a NULL !

    I am trying to set a NULL in a int column. The column allows nulls and has a foreign key. I tried cs.setNull(16,Types.INTEGER), still get this error: [IBM][SQLServer JDBC Driver][SQLServer]UPDATE statement conflicted with COLUMN FOREIGN KEY constrain

  • How to send the Error notification

    Hi,   Hi,      I am having the one scenario like , i send the one record to destination using outbound that time i stored in one table sent time and date and they are send the ACK to me that time i update the table with receiving time and date using

  • Testing a secured Web Service (Basic -Username/Password)

    Hello,    I configured security for a custom web service using [this |https://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/e08627de-9816-2a10-02b7-cbd60f7e4b2c&overridelayout=true] . I configured section 3.2 Configuring Document Authentication    

  • Lim. Financial License

    Based in the 'SAP Business One License User Types V2', the Lim. Financial License has full access to the Banking Module. But when the user goes to the Bankig Reports =>Check Register Report, the message says the Selection Criteria is not available fo