Inserting calculated fields in database queries

I have just changed from using StarOffice version 7 to version 8.
I am having difficulties in creating a calculated field in a query.
Would anyone have some ideas for me to follow?
Thanks - Dan

1.  Order as a column name could be problematical as it might conflict with the SQL 'ORDER BY'.  Wrapping it in square brackets should cater for this.
2.  You are missing some spaces.  
3.  The use of the arithmetical + operator could be problematical with dates as the string expressions, which might be interpreted as arithmetical expressions.  The + operator is used rather than the ampersand concatenation operator to suppress
Nulls, but that's not the case here.  
4.  As you are only returning columns from one table you do not need to qualify the column names with the table name.  
5.  Defining a range as on or later than the start date and before the day following the end date is more reliable as it allows for rows with date/time values on the last day of the range with a non-zero time of day element, something you cannot rule out
with complete confidence unless you have taken specific steps in the table definition to disallow such values.
So taking these points into account:
strSQL6 = _
        "SELECT [Order], [OperWorkCenter], [Created on], " & _
        "[Actfinish date]," [Actfinish date]-[Created on] AS Delta " & _
        "FROM [WOMP Work Orders] " & _
        "WHERE [Created on] >= #" & FStartDate$ & "# " & _
         "AND [Created on] < #" & FEndDate$  & "# + 1"
The FStartDate$ and FEndDate$ values must of course be in US short date format or an otherwise internationally unambiguous format such as the
ISO standard date format of YYYY-MM-DD.
Ken Sheridan, Stafford, England

Similar Messages

  • How to insert calculated field in SQ01

    I would like to add a calculated field in a query but can´t find any documentation.
    the specific problem is that I would like to add a basic mark up on some costs.
    can anyone help
    Keel

    Unless you need some very complex calculations, this may be done in SQ01. The process is not very intuitive though.
    1) In SQ01, open the query in the change mode. Go to the Field Selection screen (the 3rd one).
    2) If you need to use an existing field in calculation, give that field a "short name" (if you don't see the Short Name column, go to the menu Edit -> Short Names -> Switch On).
    3) Now create a new field. Go to the menu Edit -> Local Field -> Create. Give the field some name and descrption. Choose the properties that you need and enter the Calculation Formula using the short name from step 2 (e.g. COST * 1.10 to add 10% to the COST field).
    You can also add conditions and use more than one existing field. I always use those local fields to display the invoice value, because NETWR is always a positive number, but it should be displayed as negative for cancellations and credits.

  • Hi friends, I have a doubt in inserting a field to database table and inserting the same values in two different tables

    I have a mpp screen for a cd library management system (we are practicing on it).
    We have a main screen where a user should enter the enteries and while clicking a add button it should be inserted in a table, Here the problem rises the table name are ztransaction and zstatus.The fields in mpp are cdid,customerid,transaction id,date of issue and duedate.Now after entering all the values on clicking add button it should be inserted to database table ztransaction and the field cdid alone should be inserted both in ztransaction and zstatus.
    Thank you

    Hi Raghuram R G,
    Check for Primary key and foreign key in the Database table??? Because of this it was not inserting...check and confirm??
    Regds,
    Vijay SR

  • Linking to an Access Database (accdb) - calculated field in query

    Using Crystal Report v 14 we have a problem linking to an Access 2010 database (accdb file format).
    We created a query in the Access database with a calculated field that we want to use to link with Great Pllains database. We can see the query using the database expert and the OLEDB (ADO) data source. The problem is that the calculated field in the Access query does not show in the link manager.
    What is the best wat to link an Access table that has a job number containing hyphens (111-222-333) with the other database that has the job number stored without hyphens (111222333)? Why does our query solution not work?

    Hi,
    I'm not sure if this can be handled at the Database query level, however this can surely be handled from the report level.
    You would need to insert a subreport with Great Pllains as its datasource. The Main report's data source would be the access table.
    Next, in the Main report you would need to create a formula to remove the hyphens from the string and convert it back to number. Use this formula:
    tonumber(replace(,"-",""));
    You can then palce this formula in the details section/group section (which ever is applicable) and then link the subreports's job number field with this formula field. A record selection formula is automatically added in the subreport when you do so.
    Also, make sure the sub-report is place in the same section this formula field is placed in, otherwise you can get unexpected results.
    Hope this helps!
    -Abhilash

  • Hi, plz help me. i wanna store photos to sql database. so how to insert file field into insert record in dreamweaver cs3?

    I dont know how to insert file field into insert record in DW. i also want to know, insert dynamic table with image field. Plz help me anyone. Ty..

    ohh kk thank you bro. But How to store photos to server file. I wanna upload and display the photos in webpage. Can you send me the php code for this?

  • Insert a field calculated upon others

    Hi!
    I would like to know if I had several numeric fields, if I could display in another one their average (just display it). I mean, if I had...
    Option A: 10
    Option B: 5
    Option C: 7.5
    If I could have a field auto-calculating their average dinamically (in this case, 7.5). Is this possible using FormsCentral? This is exactly what I need and I'm afraid this is not possible.
    Thanks.

    That is correct, you can't add calculated fields on the form itself.
    The only thinkg you can do is add the average function to a new column in the Response Table to perform that computation.
    The filler won't see the average but people looking at the data will.
    Gen

  • New Calculated field question. Complicated I think.

    I have managed to create this table from a MySQL database: http://ppbm5.com/DB-PPBM5.php
    The field 'Total' is a calculated field using this SQL query:
    $query_Recordset1  = 'SELECT *, `Disk I/O`+`MPEG2-DVD`+`H264-BR`+IFNULL(`MPE On`,`MPE  Off`) As Total, `CPU`*`Cores` As Phys_Cores FROM `Personal_data` WHERE 1  ORDER BY (`Disk I/O`+`MPEG2-DVD`+`H264-BR`+IFNULL(`MPE On`,`MPE Off`)),  `Date & Time` ASC';
    So far, so good, but as you may have  noticed, there is a next field called 'Rel. Perf.' which only contains  blanks. And that is where my problems start.
    The table is sorted by 'Total' and the first record shows these figures and field names that are relevant for my question:
    Fields: 'Total'  'Disk I/O'  'MPEG2-DVD'   'H.264-BR'   'MPE On'   'MPE Off'
    Values:  131,        67,              21,                  37,              6,              64
    In addition, I use four 'weight' figures, let's say these are 0.27 , 0.30 ,  0.20 and 0.23 denoted as W1, W2, W3, W4.
    First step is to calculate four temp values, using a formula like this resulting in T1, T2, T3 and T4:
    T1 = W1 x  Total /Disk I/O; T2 =  W2 x Total/MPEG2-DVD ; T3 = W3 x Total/H.264-BR ; T4 = W4 x Total/(IFNULL(MPE On, MPE Off)
    Note that this only applies to the top record and here the SUM(T1, T2, T3, T4) results in 131, equal to the Total.
    The result of 100 x SUM(T1, T2, T3, T4)/ Total = 100 should be the 'Rel.Perf.' result for the top record.
    Now  is gets difficult. Let me call the records R1, R2, R3, ..., Rx. Now, in  the previous step we have established that the figure 100 should into  R1.
    For R2 the result of the 'Rel.Perf.' is 100 x SUM(T1 x Disk  I/O(2), T2 x MPEG2-DVD(2), T3 x (H.264-BR(2), T4 x (IFNULL(MPE on, MPE  Off)))/ Total(2)
    For R3 the result of the 'Rel.Perf.' is 100 x  SUM(T1 x Disk I/O(3), T2 x MPEG2-DVD(3), T3 x (H.264-BR(3), T4 x  (IFNULL(MPE on, MPE Off)))/ Total(3)
    etcetera for all the rest of the records in the table.
    A  complicating factor is that the reference point of the top machine  should remain fixed at 100, but when doing queries, the top machine may  not be in the query results, but all the query results for the Rel.Perf.  should be derived from these scores. Life would be infinitely easier if  one would be certain that the top machine is fixed, but that is not the  case.
    Sorry to make this such a long and complicated post, but  for those who have struggled through this long message, if you have any  suggestions on how to make this work, I would appreciate it.
    Thanks in advance.
    Harm, while non is intended.
    PS. I have been trying to generate a SQL query, using the following code:
    $query_Recordset1 = 'SELECT *, FORMAT(`Disk I/O`+`MPEG2-DVD`+`H264-BR`+IFNULL(`MPE On`,`MPE Off`),0) As Total, FORMAT((54.661*`Disk I/O`+161.25*`MPEG2-DVD`+71.66666*`H264-BR`+645*IFNULL(`MPE On`,`MPE Off`))/129,1) As RPI,`CPU`*`Cores` As Phys_Cores FROM `Personal_data` WHERE 1 ORDER BY 54.661*`Disk I/O`+161.25*`MPEG2-DVD`+71.66666*`H264-BR`+645*IFNULL(`MPE On`,`MPE Off`), `Disk I/O`+`MPEG2-DVD`+`H264-BR`+IFNULL(`MPE On`,`MPE Off`) ASC';
    For static work it is OK, but not when a new top performer submits his data.

    Hi William,
    Per my understanding that you want to count the number of the value in the field wait which is smaller then 15, right?
    I have tested on my local environment and that you can add the calculated field (Count) using the expression as below:
    =IIF(Fields!wait.Value<15,1,0)
    Insert an outside group row and then get the total count by using below expression:
    =SUM(Fields!Count.Value)
    Preview you will get the result like below:
    If your problem stil exists, please try to provide some sample data and the exprect count result you want.
    Any problem, please feel free to ask.
    Regards
    Vicky Liu
    Vicky Liu
    TechNet Community Support

  • Calculation Field to be mapped to different data object's column name in Oracle BAM 12c

    Hi,
    I am having a challenge to enable drill down to 2nd level report by passing calculation field as parameter.
    As an alternative, I am thinking to point calculation field to another data object’s column name and generate report so that I would be able to pass that as parameter to drilling report view.
    Is there any way to map calculation field to different Data object’s column name? Thanks in advance.
    Regards
    Amik Basu

    1. Yes, you can.
    SQL> create table ÜÝÞ( ßàá number(10));
    Table created.
    SQL> insert into ÜÝÞ values (10);
    1 row created.1.1 and 1.2 and 2. You can choose UTF as your default character set. It allows the user of non-English characters in VARCHAR columns in your whole database. It is not per tablespace.
    SQL> create table ÜÝÞ( ßàá varchar2(100));
    Table created.
    SQL> insert into ÜÝÞ values ('âãäçìé');
    1 row created.

  • Use calculated field(s) in other report

    Hi everyone,
    Is there a way to use a calculated field by itself in another report? I don't want to insert a sub report because it takes up too much space.
    I just need to use few fields in other calculations in the new report.
    Thank you

    The only way I can think of doing this without subreports is to save the values in a database somewhere.  In order to do this, the values would have to be calculated in the report's SQL Command data source.  (I'm guessin' that's probably not what you're looking for, but using subreports is the only other way I can think of...)
    HTH,
    Carl

  • Error upon inserting data in sql Database using stream analytics job: Datatye error conversion

    I have a data passed into the Event Hubs, queried by stream analytic job inserting it into sql database. Upon running the job, it becomes idle a few seconds after since it has an error:
    Message: Conversion from 0 to System.Boolean failed. 0 was of type - System.Int64.
    Conversion from 0 to System.Boolean failed. 0 was of type - System.Int64. Exception message at level [1], exception number [0], parent exception number [0]: Conversion from 0 to System.Boolean failed. 0 was of type - System.Int64.
    The data type in one of my field(IsHistorical) is Boolean with a value of false. The data type of the column in the sql table where this is to be inserted is of type bit. In this case, it seems that stream analytics could not convert the value "false"
    into a bit data type when inserting in sql table.
    I'm wondering if you already have encountered this problem. Could you help me resolve this problem?
    Thank you.

    Azure Stream Analytics does not have Boolean type. On input we will convert JSON Boolean value to bigint.
    Here is the list of supported types and conversions:
    https://msdn.microsoft.com/en-us/library/azure/dn835065.aspx 
    You  can fix this erro by changing column type from bit to int in SQL table schema.

  • SSRS Using WHERE in a calculated field

    Hi All,
    Im having a real issue with something that seems like it should be easier than it is.
    In my tablix I want to add the expression =Sum(Fields!ID20.Value)-Sum(Fields!ID20.Value) BUT I need to determine if another criteria is met.
    EG - I want =Sum(Fields!ID20.Value WHERE [InOut]="In")-Sum(Fields!ID20.Value WHERE [InOut]="Out")
    Many Thanks for any help

    Hi LB79,
    In Reporting Services, Aggregate functions cannot be used in calculated field expressions, since the data for calculated fields will be based on individual rows not on group basis. As a workaround, we can directly add the expression to a textbox of the tablix
    instead of using that calculated field. For detail information, please refer to the following steps:
    Right click the text box which you want to insert the calculated field, then click Expression.
    In the Expression text box, refer to the following expression:
    =sum(iif(Fields!InOut.Value ="In", Fields!ID20.Value,0),"DataSet_name")-sum(iif(Fields!InOut.Value ="Out", Fields!ID20.Value,0),"DataSet_name")
    If there are any other questions, please feel free to ask.
    Thanks,
    Katherine Xiong
    Katherine Xiong
    TechNet Community Support

  • Updatable property of Calculated Field in ViewObject does not work

    Hello,
    I have set the Updatable property of some ViewObject attributes to "while new".
    In the page those attributes are shown as <af:inputListOfValues> components.
    When creating a new row, those components properly appear as enabled and let me insert any values, since the row is new.
    However, after a following commit, once the table in the page is refreshed, I still see some components enabled on the row I committed before. This only happens with attributes based on calculated fields, not with those based on real table fields, as if the "while new" property specified on the ViewObject calculated fields was ignored.
    Do you know why? Is there a solution or work around?
    Below are the ViewObject XML section and the af:component definition based on the attribute.
    <ViewAttribute
    Name="Cod"
    IsPersistent="false"
    PrecisionRule="true"
    Precision="15"
    Type="java.lang.String"
    ColumnType="VARCHAR2"
    AliasName="COD"
    Expression="COD"
    SQLType="VARCHAR"
    IsUpdateable="while_insert"
    LOVName="LOV_Cod">
    <DesignTime>
    <Attr Name="_DisplaySize" Value="15"/>
    </DesignTime>
    <Properties>
    <SchemaBasedProperties>
    <CONTROLTYPE
    Value="input_text_lov"/>
    </SchemaBasedProperties>
    </Properties>
    </ViewAttribute>
    <af:inputListOfValues id="ilov1"
    popupTitle="Search and Select: #{bindings.BLOCK.hints.Cod.label}"
    value="#{row.bindings.Cod.inputValue}"
    model="#{row.bindings.Cod.listOfValuesModel}"
    required="#{bindings.BLOCK.hints.Cod.mandatory}"
    columns="#{bindings.BLOCK.hints.Cod.displayWidth}"
    shortDesc="#{bindings.BLOCK.hints.Cod.tooltip}"
    autoSubmit="true">
    <f:validator binding="#{row.bindings.Cod.validator}"/>
    </af:inputListOfValues>

    Helga,
    The question is what does this "require" flag do? We read the book of life (cl_htmlb_inputfield), and see that this flag only controls in the first instance a little red * that is rendered next to the input field. This is a pure visualization for the user of the page.
    In addition you can ask that a check be done in the browser. This you can do with:
      <htmlb:inputField  id = "wander"
                         value = "E"
                         required = "TRUE"
                         doValidate="true" />
    However, I would not serious recommend this. Now even if you user presses a cancel button, or link, or breadcrumb, or..., the check will still complain.
    What we currectly do (and recommend), is to set the required flag on the <htmlb:<b>label</b>/> tag. And then do the actual checking on the server (must be done in anycase). If no value, or not correct, then also set the "invalid" flag, render out error message and redo page.
    ++bcm

  • How to populate a field from database through personalization

    I need to populate value of a field from database on self service transaction web page. This field is not configured as EIT or SIT, nor available in seeded transaction.I need to know abt creating some item through personalization where i can write a query . This item will execute the query and display the returned value on the page or something on the similar line.
    Thanks in advance,
    Tanveer

    This workaround should be used as a one time approach till you move to 11.5.10 CU3.
    Here are the details,
    You just need to add the following tags inside the site or function level customization document, remember it should be either site or function only no other levels are supported for adding a new item.
    before adding the following tags you need to find out the following details,
    1. what is the last item in the advancedTable, column or columnGroup in the base metadata. Do not conside the columns inside the columnGroups for this, just the last item which might be a column or a columngroup. Get the if of that item.
    2. You should know what is the view instance and viewattribute you will be attaching
    3. Remember you can only add columns through personalization and not columnGroups.
    4. Replace the appropriate values for the properties amrked with {...} with your own values. You can change the other properties to reflect any specific requirement you want. Make sure you provide correct values.
    <insert after="{the id you got from step 1}">
    <oa:column id="{yourid}" adminCustomizable="true" bandingShade="none"
    cellNoWrapFormat="false" columnDataFormat="textFormat" displayGrid="true"
    rendered="true" scope="." totalValue="false" userCustomizable="false"
    xmlns:oa="http://xmlns.oracle.com/oa">
    <ui:columnHeader xmlns:ui="http://xmlns.oracle.com/uix/ui">
    <oa:sortableHeader id="{yourid}" adminCustomizable="true"
    cellNoWrapFormat="false" initSortSeq="none" prompt="{your prompt}"
    rendered="true" required="no" scope="." sortState="no"
    userCustomizable="false"/>
    </ui:columnHeader>
    <ui:contents xmlns:ui="http://xmlns.oracle.com/uix/ui">
    <oa:messageStyledText id="{yourid}" adminCustomizable="true"
    cellNoWrapFormat="false" dataType="VARCHAR2" initSortSeq="none" queryable="false" rendered="true" required="no" scope="."
    selectiveSearchCriteria="false"
    serverUnvalidated="false" sortState="no" tipType="none" totalValue="false"
    userCustomizable="false" vAlign="middle" viewAttr="{your view attribute}" viewName="{your view instance name}"
    warnAboutChanges="true"/>
    </ui:contents>
    </oa:column>
    </insert>
    You can insert these tags at the end of any existing tags within the <modifications>
    </modifications> tag in the document.

  • Running total of calculated field in pivot

    VERSION: ORACLE 11
    TABLE:
    create table chart_detail (
    DIS        NUMBER,
    BLD_MO VARCHAR2(7),
    BLD        NUMBER(10),
    RPLC      NUMBER(10));DATA:
    insert into chart_detail values (60,'2011-03',0,2);
    insert into chart_detail values (150,'2011-04',10572,0);
    insert into chart_detail values (120,'2011-04',26449,5);
    insert into chart_detail values (30,'2011-04',0,1);
    insert into chart_detail values (60,'2011-04',0,7);
    insert into chart_detail values (90,'2011-04',0,9);
    insert into chart_detail values (120,'2011-05',5714,0);
    insert into chart_detail values (90,'2011-05',24557,1);
    insert into chart_detail values (60,'2011-05',0,4);
    insert into chart_detail values (30,'2011-05',0,0);
    COMMIT;EXPECTED RESULTS:
         2011-04                    2011-05               
    DIS     RPLC     BLD     TBLD     IPTV     RPLC     BLD     TBLD     IPTV
    30     1     0     37021     0.03     0     0     30271     0.00
    60     7     0     37021     0.22     4     0     30271     0.13
    90     9     0     37021     0.46     1     24557     30271     0.17
    120     5     26449     37021     0.59     0     5714     5714     0.17
    150     0     10572     10572     0.59               0     
    180               0                    0     
    TOTAL     22     37021               5     30271          PROBLEM: I need to have a running total of IPTV like in the above example. I can get the IPTV for each DIS/bld_mo but I don't know how to get the running total of it. In the script below I just used an example where I tried summing the IPTV like was done for build. I know it can't be done that way because IPTV is a calculated field in the query but if I substitute "APR_IPTV" with the formula for IPTV I get an error that window functions aren't allowed here. I do not know a way around this. I commented out the bad piece of code.
    PROBLEM SCRIPT:
    WITH  pivot_results  AS
      SELECT    dis
      ,    NVL (apr11_rep,  0)  AS apr11_rep
      ,    NVL (apr11_bld,   0)  AS apr11_bld
      ,    NVL ( SUM (apr11_bld)
                      OVER (ORDER BY dis DESC)
                    ,                 0
                    )        AS apr11_tbld
    ,      DECODE(NVL ( SUM (apr11_bld)
                      OVER (ORDER BY dis DESC)
                    ,                 0),0,0,ROUND(NVL(apr11_rep, 0)*1000/ NVL ( SUM (apr11_bld)
                      OVER (ORDER BY dis DESC)
                    ,                 0),2
                    ))        AS apr11_iptv               
    ,      NVL ( SUM (apr11_iptv)
                      OVER (ORDER BY dis DESC)
                    ,                 0
                    )        AS apr11_tiptv  
      ,    NVL (may11_rep,  0)  AS may11_rep
      ,    NVL (may11_bld,   0)  AS may11_bld
      ,    NVL ( SUM (may11_bld)
                      OVER (ORDER BY dis DESC)
                    ,                 0
                    )        AS may11_tbld
    ,      DECODE(NVL ( SUM (may11_bld)
                      OVER (ORDER BY dis DESC)
                    ,                 0),0,0,ROUND(NVL(may11_rep, 0)*1000/ NVL ( SUM (may11_bld)
                      OVER (ORDER BY dis DESC)
                    ,                 0),2
                    ))        AS may11_iptv
    ,      DECODE(NVL ( SUM (may11_bld)
                      OVER (ORDER BY dis DESC)
                    ,                 0),0,0,ROUND(NVL(may11_rep, 0)*1000/ NVL ( SUM (may11_bld)
                      OVER (ORDER BY dis DESC)
                    ,                 0),2
                    ))        AS may11_tiptv               
      FROM     chart_detail
      PIVOT     (  MAX (rplc)  AS rep
              ,  MAX (bld)  AS bld
              FOR  bld_mo   IN ( '2011-04'  AS apr11
                                             , '2011-05'  AS may11
    SELECT    CASE
            WHEN  GROUPING (dis) = 0
            THEN  TO_CHAR (dis)
            ELSE  'Total'
        END      AS dis
    ,    SUM (apr11_rep)  AS apr11_rep
    ,    SUM (apr11_bld)  AS apr11_bld
    ,    SUM (apr11_tbld) AS apr11_tbld
    ,    CASE
            WHEN  GROUPING (dis) = 0
            THEN  SUM (apr11_iptv)
        END      AS apr11_iptv
    ,    SUM (apr11_tiptv) AS apr11_tiptv
    ,    CASE
            WHEN  GROUPING (dis) = 0
            THEN  SUM (apr11_tpiptv)
        END      AS apr11_tiptv
    ,    SUM (may11_rep)  AS may11_rep
    ,    SUM (may11_bld)  AS may11_bld
    ,    SUM (may11_tbld) AS may11_tbld
    ,    CASE
            WHEN  GROUPING (dis) = 0
            THEN  SUM (may11_iptv)
        END      AS may11_iptv   
    FROM    pivot_results
    GROUP BY  ROLLUP (dis)
    ORDER BY  pivot_results.dis
    ;Thank you,

    Hi,
    So you know how to compute iptv for an individual row; the problem now is that you want to get a running total of iptv; is that it?
    The problem there is that computing iptv requires an analytic function, and analytic functions can't be nested. To get the results of nesting f (g (x)), where f and g are analytic funtions, you have to compute g in a sub-query, and then use the results as the argument to f in a super-query.
    Here's how to apply that to your situation:
    WITH  pivot_results  AS
         SELECT    dis
    -- April, 2011
           ,           NVL (apr11_rep,   0)  AS apr11_rep
           ,           NVL (apr11_bld,   0)  AS apr11_bld
           ,           NVL ( SUM (apr11_bld)
                                       OVER (ORDER BY dis DESC)
                          , 0
                          )               AS apr11_tbld
         ,      NVL ( 1000 * apr11_rep
                              / NULLIF ( SUM (apr11_bld) OVER (ORDER BY dis DESC)
                                          , 0
                   , 0
                   )               AS apr11_iptv
    -- May, 2011
           ,           NVL (may11_rep,   0)  AS may11_rep
           ,           NVL (may11_bld,   0)  AS may11_bld
           ,           NVL ( SUM (may11_bld)
                                       OVER (ORDER BY dis DESC)
                          , 0
                          )               AS may11_tbld
         ,      NVL ( 1000 * may11_rep
                              / NULLIF ( SUM (may11_bld) OVER (ORDER BY dis DESC)
                                          , 0
                   , 0
                   )               AS may11_iptv
           FROM     chart_detail
           PIVOT    (    MAX (rplc)  AS rep
                    ,    MAX (bld)   AS bld
                    FOR  bld_mo   IN ( '2011-04'  AS apr11
                                      , '2011-05'  AS may11
    SELECT    CASE
                  WHEN  GROUPING (dis) = 0
                  THEN  TO_CHAR (dis)
                  ELSE  'Total'
               END      AS dis
    -- April 2011
    ,           SUM (apr11_rep)  AS apr11_rep
    ,           SUM (apr11_bld)  AS apr11_bld
    ,           SUM (apr11_tbld) AS apr11_tbld
    ,           CASE
                  WHEN  GROUPING (dis) = 0
                  THEN  ROUND ( SUM (SUM (apr11_iptv))
                                          OVER (ORDER BY  dis)
                      , 2
               END      AS apr11_iptv
    -- May 2011
    ,           SUM (may11_rep)  AS may11_rep
    ,           SUM (may11_bld)  AS may11_bld
    ,           SUM (may11_tbld) AS may11_tbld
    ,           CASE
                  WHEN  GROUPING (dis) = 0
                  THEN  ROUND ( SUM (SUM (may11_iptv))
                                          OVER (ORDER BY  dis)
                      , 2
               END      AS may11_iptv
    FROM      pivot_results
    GROUP BY  ROLLUP (dis)
    ORDER BY  pivot_results.dis
    ;Output:
          APR11  APR11   APR11  APR11 MAY11  MAY11   MAY11  MAY11
    DIS    _REP   _BLD   _TBLD  _IPTV  _REP   _BLD   _TBLD  _IPTV
    30        1      0   37021    .03     0      0   30271    .00
    60        7      0   37021    .22     4      0   30271    .13
    90        9      0   37021    .46     1  24557   30271    .17
    120       5  26449   37021    .59     0   5714    5714    .17
    150       0  10572   10572    .59     0      0       0    .17
    Total    22  37021  158656            5  30271   96527As you can see, this is not quite what you wanted on the row where dis='150'. You asked for NULLS in the may11_rep, may11_bld and may11_iptv columns. You can get those results if you need them; just explain the rules that govern whether to display the values and when to display NULL.
    The way you posted the sample data and results, and the quantity of sample data were all excellent; it really helped me find a solution. Thanks.
    It would have also helped it you had explained how iptv is computed. Basically, iptv = 1000 * rep / tbld, right?
    It looks like most of this code:
    ,      DECODE(NVL ( SUM (may11_bld)
                      OVER (ORDER BY dis DESC)
                    ,                 0),0,0,ROUND(NVL(may11_rep, 0)*1000/ NVL ( SUM (may11_bld)
                      OVER (ORDER BY dis DESC)
                    ,                 0),2
                    ))        AS may11_iptvwas a way of avoiding divide by 0 errors; it would have been helpful if you had explained that.

  • Project Server Enterprise Text1-40 task level fields in Database?

    Hello,
    There are some custom enterprise text fields available for each entity, such as Enterprise Text fields 1-40 for Tasks or Resource etc.
    documented here:
    http://office.microsoft.com/en-us/project-help/available-fields-reference-HA010370279.aspx#BM2
    more:
    http://office.microsoft.com/en-us/project-help/enterprise-text1-40-fields-HP001023958.aspx?CTT=5&origin=HA010370279
    Now user can easily insert these fields to Project views and insert/modify data of this field. however these fields are not available within reporting databases to be queried for custom reporting.
    understanding is that you can only use enterprise custom fields for reporting, but at the same time these fields are also available to be included in views and knows as Enterprise fields and not
    local fields. the only additional caption available for these fields is that "Project Professional only".
    but its for PP only, then why are they available within views? which means this data is also available somewhere in database.
    Now, based on this assumption, does any one knows that how to retrieve this task level Enterprise Text1 field using query?
    thanks.
    Khurram Jamshed - MBA, PMP, MCTS, MCITP (
    Blog, Twitter, Linkedin )
    If you found this post helpful, please “Vote as Helpful”. If it answered your question, please “Mark as Answer”.

    Hi , thanks James for pointing out to the rite source, i already reached to this table prior to ur reply though :)
    i agree that its not supported to read from published database, and i always stick with the recommendation to customers all the time. However you can understand that there are times when envrionmental factors are unavoidable :)
    on other note, what i do not really understand is that why these fields are even available to be used in views??
    may be someone able to shed light on this, for now i am marking ur reply as an answer closing this thread.
    thanks again, cheers mate.
    Khurram Jamshed - MBA, PMP, MCTS, MCITP (
    Blog, Twitter, Linkedin )
    If you found this post helpful, please “Vote as Helpful”. If it answered your question, please “Mark as Answer”.

Maybe you are looking for

  • How do I use one song for all Theme sub-menus?

    I'm using IDVD '08.I have created a theme with 3 chapter selection sub menus. Is there any way to choose a single song that plays from start to finish (and then loops normally) regardless of which submenu you happen to be in? I know how to add the sa

  • How do I make my printer wireless

    I have a HP Photosmart C4680 and I am needing to set it up as a wireless printer instead of having to keep it pluged into my lap top. Can you Please help. I already have wireless high speed internet.

  • Printing on an HP Officejet Pro 8500 wireless

    How do you get the Ipad to recognize my HP Officejet Pro 8500 wireless, and vise versa?

  • How to reduce number of colors in an image

    I am fairly new to Photoshop and I'm learning as I go, so I apologize for using your time.  I haven't worked with images that much - I've used MS Digital Image Suite with photos from my camera.  That's the extent of my knowledge. I am taking over a j

  • Why is there no "package" command in AI?

    Perhaps I'm just overlooking it, is there a "package" function in AI? Or PS for that matter? InDesign will collect all of your images (and more importantly), fonts, in one place with one command. Is there a similar function in AI without having to bu