How to make addition of few records in query

Hello.
Hope you will understand this.
We have one view with select on 5 different tables.
We get a lot of records from this query. Some of those records are special. And we have to sum those records and present them as one.
Example.:
Now the query results looks like:
project, parameter, value
12, '2', 5
20, '742', 0
20, '743', 1
30, '5', 1
20, '744', 1
I want this result:
12, '2', 5
20, 'addition of 742, 743, 744', 2
30, '5', 1
How can we do that?
Thanks.

with t as (
           select 12 project, '2' parameter, 5 value from dual union all
           select 20, '742', 0 from dual union all
           select 20, '743', 1 from dual union all
           select 30, '5', 1 from dual union all
           select 20, '744', 1 from dual
select  project, case when cpt>1  then 'addition of  '||  res else res end  res,
            value,cpt
from t
model
return updated rows
partition by ( project )
dimension by ( row_number() over (partition by project ORDER BY parameter asc) as position )
measures ( cast( parameter as varchar2(1000) ) as res,
                    sum(value)over(partition by project)  value,
count(parameter)over(partition by project) cpt )
rules
upsert
iterate( 1000 )
until ( presentv(res[iteration_number+2],1,0) = 0 )
( res[1] =    res[1] || case when res[iteration_number+2]  is present then
                                              ',' || res[iteration_number+2]   end   )
order by project
SQL> with t as (
  2             select 12 project, '2' parameter, 5 value from dual union all
  3             select 20, '742', 0 from dual union all
  4             select 20, '743', 1 from dual union all
  5             select 30, '5', 1 from dual union all
  6             select 20, '744', 1 from dual
  7            )
  8  select  project, case when cpt>1  then 'addition of  '||  res else res end  res,
  9              value,cpt
10  from t
11  model
12  return updated rows
13  partition by ( project )
14  dimension by ( row_number() over (partition by project ORDER BY parameter asc) as position )
15  measures ( cast( parameter as varchar2(1000) ) as res,
16                      sum(value)over(partition by project)  value,
17   count(parameter)over(partition by project) cpt )
18  rules
19  upsert
20  iterate( 1000 )
21  until ( presentv(res[iteration_number+2],1,0) = 0 )
22  ( res[1] =    res[1] || case when res[iteration_number+2]  is present then
23                                                ',' || res[iteration_number+2]   end   )
24  order by project
25  /
   PROJECT RES                                                     VALUE        CPT
        12 2                                                           5          1
        20 addition of  742,743,744                                    2          3
        30 5                                                           1          1
SQL>

Similar Messages

  • How to make additional attributes mandatory

    Hi Experts,
    I want to make Additional fields mandatory.
    I went to CT04 and ticked entry required check box.
    But this tick gives only a warning message but not the error.
    How I can achieve the effect like error.
    I dont want to get DIR saved without Additional attributes.

    Hi Sunil,
    Please check following fields which we have used for my current project for BDC purpose:
    doknr(025) type c,
    dokar(003) type c,
    doktl(003) type c,
    dokvr(002) type c,
    dktxt(040) type c,
    stabk(002) type c,
    labor(003) type c,
    begru(004) type c,
    mwert_01(40) type c,
    mwert_02(40) type c,
    mwert_03(40) type c,
    mwert_04(40) type c,
    mwert_05(40) type c,
    mwert_06(40) type c,
    mwert_07(40) type c,
    mwert_08(40) type c,
    mwert_09(40) type c,
    mwert_10(40) type c,
    matnr(18) type c,
    lifnr(10) type c,
    These are some additional fields used while coding BDC.
    Now , with help of abap'r please check for enhancement spots and coding needs to be done to achieve your requirement.
    I hope this will help more
    Regards,
    Ravindra

  • How to make The Java Screen Recorder similar to this one?

    Can u talk about this how can make this code with java?
    http://www.devharbor.com/java/300-Screen-Recorder.html
    The author of this application says this maked by Java Swing.
    My Question is:
    What is Java Swing?
    It's easy to make this app?
    What API/Component needed for export video to MP4 Format like this application?
    How can make a similar application for education purpose with Java.
    Thanks

    808154 wrote:
    :) Thank you for answering my question,
    but impossible in nothing bro, Yea, that's what Aleksey Vayner claimed and he didn't do so well.
    I need to know about swing and start to work with java to develop this software and if I need some help I ask here.Clearly yes. You also need to make simple programs and practice for a long time before you're gonna be able to write a screen recorder with MP4 output.
    I try to develop this before 3-4 years ;)I guess 3-4 years is a realistic goal, if you really concentrate on learning Java.

  • Solaris 10 x86 DL-360 How to make additional NICS Show.

    Installing Solaris 10 x86 on a DL-360 with 4 NIC's. The server comes normally with 2 built in.
    The first was seen fine..
    bge0
    When I tried to use the 2nd one, bge1, I had to plumb it first.
    ifconfig bge1 plumbNo problem...
    Now I need to use the 3rd port but the same command is not working.
    I would assume that it would be bge2 ??

    If I understand you correctly, you have two gigabit Ethernet ports as a part of your computer's systemboard, and you have two more Ethernet ports because there are add-in card or cards.
    The bge device name is a result of the particular chipset circuitry
    and is not a generic term for just any old network port.
    It is a name derived from a BroadCom Gigabit Ethernet chipset.
    So ... who created the chipsets for the 3rd and 4th network ports?
    ipbr is an example from Intel.
    le was a common Lowspeed Ethernet (10mbit) circuit in Sun systems in the last century.
    hme was a common integrated Highspeed Media Ethernet interface (10/100mbit) on Sun systemboards.
    eri is a common Ethernet Rio Interface (10/100) on newer Sun systemboards.
    elx is a name associated with 3COM EtherLink chipsets.
    dnet is an interface from the DEC21x4x chipsets and could be 10mbit or 10/100mbit adapters per whichever DEC chip was used.
    You're going to have to determine what you actually have, confirm you have the appropriate software packages for that hardware, and then you may have a chance to plumb them.

  • Double record make it to single record in Query for perticular period in BW

    Hi
    In my ODS some of the records got doubled  from Mar 17th to May 31st  but from 1st of june its correct , its Open orders, i dont want to reload data again to that ODS , because its Open orders anyways its going to be close after some time  , automatically it will become "0".
    So i want tocalculate in query itself to make it single
    please some one suggest me how can i do for that perticular period divided by 2
    for example  :
    Open Orders (its In ODS)
    120
    140
    20
    10
    50
    I need output should be 
    60
    120
    10
    5
    25
    Note : BW 3.1 Version
    Thanks,
    GAl
    12

    hi,
       You can create a a formula variable with replacement path on the Period(replace with key of Posting Date/Calday) and use it for comprision in the fomula like below
    if posting date is in between date1 and date2
      order value = order value/2.
    else
    ordervalue = ordervale.
    In Bex Query designer you will have the below formula
    (posting date formula variable >date1 and posting date formula variable <date2) * (Ordervalue/2) + ordervalue
    But also note that when the order is closed the value of order value will net become zero since the value is doubled up in the DSO , when the delta records come into DSO the order will be closed but the value will still not become zero since the reverse image will give negative value of the actual order value.
       For example if your order value is 100, in your DSO it will currently show the value is 200(doubled up). In the Delta the reverse value come as -100. So the final value will still be 100(200-100).
    So the best solution will be to do selective deletion
    Thanks,
    Praveen
    Edited by: Praveen kumar kamineni on Jun 11, 2010 11:06 AM

  • How to make an index use in a query execution

    Hi,
    I have the below query for which ename column has an index. As of my knowledge below queries 1st and 2st will not use index. Hence i used the 3rd statement and that too its not using the index. Finally i used the 4th query, but even the 4th query is not using the index. Then how do i make this query to use my index??? Do i need to create a function based index for this??? Is that the final option????
    1. select * from emp where ename !='BH' ;
    2. select * from emp where ename <> 'BH';
    3. select * from emp where ename not in ('BH');
    4. select * from emp where ename < 'BH' or ename > 'BH';
    Regards,
    007
    Edited by: 007 on Jun 6, 2013 7:56 AM
    Edited by: 007 on Jun 6, 2013 8:06 AM
    Edited by: 007 on Jun 6, 2013 8:06 AM
    Edited by: 007 on Jun 6, 2013 8:06 AM
    Edited by: 007 on Jun 6, 2013 8:12 AM

    Sorry 007, I really thought you were posting a trick question as on the OCP tests.
    Anyway, as Justin mentioned, if you have an index on ename, it may be used when doing a comparison predicate statement with the ename value.
    What it depends on are several other things: stats, how many rows in the table, use of an index hint, etc.
    Rather than questioning the group on this, why not just turn on autotrace and run the query for the different scenarios.
    The output will show you if it used the index, number of rows returned, blocks read, etc.
    SQL> create table emp (ename  varchar2(40));
    Table created.
    SQL> insert into emp select username from sys.dba_users;
    25 rows created.
    SQL> commit;
    Commit complete.
    SQL> set autotrace on
    SQL> select * from emp where ename != 'SYSTEM';
    Execution Plan
    Plan hash value: 2951343571
    | Id  | Operation        | Name      | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT |           |    24 |   528 |     1   (0)| 00:00:01 |
    |*  1 |  INDEX FULL SCAN | ENAME_IDX |    24 |   528 |     1   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       1 - filter("ENAME"<>'SYSTEM')As you can see, the above used an index, even though there were only 25 rows in the table.
    You can test each of your scenarios, one by one, including use of a hint.

  • How to make a function out of a query

    Hi,
    I have the following query:
    select
    to_date(sysdate, 'DD.MM.YYYY') as "FULL_DATE",
    to_number(to_char(sysdate, 'D')) as "DAY_OF_WEEK",
    to_number(to_char(sysdate, 'DD')) as "DAY_NUMBER_IN CALENDAR_MONTH",
    to_number(to_char(sysdate, 'DDD')) as "DAY_NUMBER_IN CALENDAR_YEAR"
    from
    dual
    how to I make a funtion where I can input a start and an ending date and it calculates allt the rows fow the days in between?
    Thanks,
    Walter

    drop type mytabletype;
    create or replace type mytype as object (
    full_date date,
    dow number,
    daynum_m number,
    daynum_y number
    create or replace type mytabletype as table of mytype;
    create or replace function myfunc (p_date in date) return mytabletype pipelined as
      cursor cur_mycur is
      select
        to_date(p_date, 'DD.MM.YYYY') as "FULL_DATE",
        to_number(to_char(p_date, 'D')) as "DAY_OF_WEEK",
        to_number(to_char(p_date, 'DD')) as "DAY_NUMBER_IN_CALENDAR_MONTH",
        to_number(to_char(p_date, 'DDD')) as "DAY_NUMBER_IN_CALENDAR_YEAR"
        from dual;
      x mytype := mytype(null,null,null,null);
    begin
      for i in cur_mycur
      loop
        x := mytype(i.full_date,i.day_of_week,i.day_number_in_calendar_month,i.day_number_in_calendar_year);
        pipe row(x);
      end loop;
    end;
    sho err
    select * from table(myfunc(sysdate));
    select * from table(myfunc(to_date('15/09/2006','dd/mm/yyyy')));is this what you're after.
    If so I suggest you take it away, and get an understanding for it. It's a very useful technique to know.
    I know it doesn't do all the days between 2 dates, but that should be something you can do with a little thought.
    Regards
    Message was edited by:
    blushadow

  • How to make an XML file from SQL query on local disc (c:\temp)?

    This query shows me XML results, but can I somehow make an XML file to local disc?
    Thanks.
    DECLARE @IMO NUMERIC(8,0)
    DECLARE @Counter INT
    SELECT @Counter = 1
    WHILE ( @Counter <15 )
    BEGIN
    SET @IMO = (SELECT ImoNo from Vessel where ID=@Counter)
    SELECT top 1
    @IMO as ImoNumber,
    VesselName,
    Time,
    lat as CurrentLatitude,
    lon as CurrentLongitude,
    sog as SpeedOverGround,
    cog as CourseOverGround,
    hdg as HeadingInDegrees,
    GoingToCountry = (SELECT TOP 1 CountryName
    FROM ShipSchedule
    WHERE ImoNo = @IMO and DestPosArrived = 'false'
    ORDER BY DestPosETA ),
    GoingToHarbour = (SELECT TOP 1 Harbour
    FROM ShipSchedule
    WHERE ImoNo = @IMO and DestPosArrived = 'false'
    ORDER BY DestPosETA ),
    DestinationLatitude = (SELECT TOP 1 DestPosLAT
    FROM ShipSchedule
    WHERE ImoNo = @IMO and DestPosArrived = 'false'
    ORDER BY DestPosETA ) ,
    DestinationLongitude = (SELECT TOP 1 DestPosLON
    FROM ShipSchedule
    WHERE ImoNo = @IMO and DestPosArrived = 'false'
    ORDER BY DestPosETA ),
    ArrivalTime = (SELECT TOP 1 DestPosETA
    FROM ShipSchedule
    WHERE ImoNo = @IMO and DestPosArrived = 'false'
    ORDER BY DestPosETA ),
    GoingFromCountry = (SELECT TOP 1 CountryName
    FROM ShipSchedule
    WHERE ImoNo = @IMO and DestPosArrived = 'true'
    ORDER BY DestPosETA desc),
    GoingFromHarbour = (SELECT TOP 1 Harbour
    FROM ShipSchedule
    WHERE ImoNo = @IMO and DestPosArrived = 'true'
    ORDER BY DestPosETA desc),
    DepartureTime = (SELECT TOP 1 DestPosETD
    FROM ShipSchedule
    WHERE ImoNo = @IMO and DestPosArrived = 'true'
    ORDER BY DestPosETA desc)
    FROM Position
    WHERE ImoNo = @IMO
    order by time desc
    for Xml AUTO,elements,root('SplosnaPlovba')
    SELECT @Counter = @Counter + 1
    END

    You can use bcp with query out option
    use your above query as the source query and use queryout option after specifying destination as your required local file path (specify extension as .xml)
    see
    http://visakhm.blogspot.com/2013/10/bcp-out-custom-format-data-to-flat-file.html
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • How do I select top 100 records in query

    I would like to get only the first 100 or 200 records in a query. In Access query, it is TOP 100, is there an equal in Oracle sql?
    Thanks!

    select * from your_table
    where rownum < 101;

  • How to make dynamic report heading in bex query

    Hi Experts,
    i have a bex query for the following rows and columns.
    Proj   WBS   NETWROK   ACTIVITY  are in Rows.  
    Scope  work      total work are in Columns.
    now i have to    show  the report heading dynamically based on proj.
    HEADING1.                         PROJ TEXT
    HEADIND2                       REPORT FROM    XXX  TO YYY   where XXX & YYY  are dates input by the user on selection screen.
    Please help me how i can achieve this heading in BEX.
    Regards
    vikas

    Hi,
    If you are using BEx analyzer :
    On the top yo will find button say Insertnavigation pan, here you will get option to display the rows ( in your case Project) look for multiple options like tab dimension, display setting - explore it
    If you are using BOBJ ANALYSIS, there also in display setting you have options to display variables, filters and even the characteristics.
    Thank-You.
    Regards,
    VB

  • VPD - How to make the where clause a correlated query

    Hi,
    My VPD function has the following where clause:
    where_clause:= ' project_id in (select object_id from pa_project_classes p'||
    ' where p.class_category='||''''||l_cat||''''||
    ' and p.CLASS_CODE='||''''||l_class||''''||
    ' and p.OBJECT_TYPE=''PA_PROJECTS'''||
    The problem is that the subquery is not using the unique key defined on the table pa_project_classes. What I need is something as follows:
    where_clause:= ' project_id in (select object_id from pa_project_classes p'||
    ' where p.class_category='||''''||l_cat||''''||
    ' and p.CLASS_CODE='||''''||l_class||''''||
    ' and p.OBJECT_TYPE=''PA_PROJECTS'''||
    ' and p.object_id=mainquery.project_id ||
    The problem is that since the table pa_project_classes also has a column project_id, I have to prefix the column name by the alias of the main query like 'mainquery.project_id'. However this seems impossible as main query is not unknown .
    I would be grateful if you could suggest any workaround or solution.
    Thanks

    Just have a look over these two statements if it solves your problem
    one time where clause
    Set_Block_Property('BLOCK_NAME',ONETIME_WHERE,your form item);
    dynamic where clause
    set_block_property('BLOCK_NAME'default_where, your form itme)
    you can where clause at run time from any procedure or some triggers

  • How to make a "SSWA JSP Function"  as query Only in Oracle 11i or R12

    Please someone help me in making a SSWA JSP Page as read only..
    For "forms" we use a parameter QUERY_ONLY="YES",what is the procedure for making a JSP as read only?

    All the enterable fields of an OA Framework Page can be made Read Only via personalization. Also you can disable/hide the transaction buttons. This way the page would become query only.

  • How to make few records editable in oracle ADF form.

    Hi,
    I am working on one scenario. here, we are sending few records to user in an ADF task form, using BPEL Human task. Now, the requirement is to put a checkbox in each row and enable that particular row-fields for editing purpose.
    please respond if there is a way to put any condition in check box design to enable row-data for editing.
    thanks,
    rps

    Hi,
    actually to implement check boxes in front of a table you need some sort of transient field that can keep persistence. One way of achieving this is to wrap the BPEL service in a WS proxy client and create a POJO DC from it. This then allows you to add an additional field to implement a solution similar to this in ADF BC
    http://sameh-nassar.blogspot.com/2009/12/use-checkbox-for-selecting-multiple.html
    Because ADF Faces tables are stamped upon rendering, rows arent created with instances of the cell renderer. For this reason you need to keep track of the select state in the model, which you can do using a transient attribute, which then makes sure the select information is part of the row object. So similar as today, you would parse the available rows but - before changing the update state - check if the user intended the update
    Frank

  • How to make few columns of single record inactive in Table conrol?

    Hi all,
    Scenario is like this : i have one table control , it is displaying 10 records , in that first four columns are editable. Now my requirement is, whenever record having intial values( suppose one record having initial values among ten) except key field , we need to deactive that particular  record , now table control  should contain ten records , but nine records are in editable state and one record in non editable state .
    How to make few columns of single record inactive in Table conrol?
    Thanks in advance.

    hi there...
    select the column that u want to convert to non editable mode in the screen layout. then double click on it. go to the attributes tab and uncheck the input chk box. the check box will become disabled for input. u can do this for any number of columns.
    if u want to do it dyanamically, loop at screen. check for the screen element's name. when itmatches the column u want to disable, simply set the input value as 0.
    dont forget to modify sscreen after setting the attribute values.
    i hope this helps.
    do reward if helpful.

  • I was trying to make a new screen recording using quicktimeplay, but when I watched the video after recording it all I could hear was me talking while the video was showing on the screen. How do I turn off that recording and turn the right one on? thanks

    I was trying to make a new screen recording using quicktimeplay, but when I watched the video after recording it all I could hear was me talking while the video was showing on the screen. How do I turn off that recording and turn the right one on? thanks

    Hi j2399123,
    It sounds like your screen recording is doing what it was designed to do, capture what is happening on your screen, with optional voice over with the microphone.
    Screen recording is for recording what you see on the screen, it is not a "video capture" option, like for capturing a movie with sound that is playing on your screen.
    For the QuickTime recording options, check out "Recording with QuickTime Player" in
    Mac Basics: QuickTime Player creates, plays, edits, and shares video and audio files
    http://support.apple.com/kb/ht4024
    And for screen recording specifically, there's
    QuickTime Player 10.x: Record your computer’s screen
    http://support.apple.com/kb/PH5882
    Thank you for thinking of Apple Support Communities for your support needs.
    Nubz

Maybe you are looking for

  • Office 365 Pro Plus - Fail to update Build version when user clicks 'Cancel'

    I'm planning to deliver Office 365 Pro Plus updates via SCCM 2007 where i can control the build versions and use the already available SCCM to do so. My issue is around the user clicking "Cancel" when they are prompted with the notification window to

  • Files Not Displaying

    I run itunes on a Windows XP machine. It usually works just fine, was using it this morning. However, about midafternoon, I used iTunes to play a song I'd downloaded from the web. When it opened, it only showed that song in my library. None of the ot

  • Upgrade iTunes 11 keeps disconnecting from apple tv

    Upon upgrading to iTunes 11, I've developed a connect problem to my Apple TV. It will plAy music from my library for about 45 minuets then just stop. When I go To reconnect my computer/library. It cannot find my computer. Just the spinning white whee

  • Need to know hardware specifics for T410 2522-CP4

    NewEgg is selling some reburbished T410s, but they are not able to give complete hardware specs. The list the item as T410 with part number 2522-CP4.  What I'm looking to determine is: 1.  What the exact processor number is.  All I know is "Intel Cor

  • External ITS change button text

    We are just implementing ESS 50.4 using WAS 4.7, Portal 6.0, and external ITS. In the Enrollment IAC, transaction PZ14, SAP Template Button href=URLPLAN button=TXT_INFO iconName=b_info The button displays the word 'Information' and we need to change