Group by function field

The first field in a select statement is based on a function and returns a number less than 1000.
I would like to only display the multiple records of that field.
The statement would normally be:
select first_field,...
from ...
group by first_field
having count(*) > 1.
Since first_field is a function, I keep getting an error in the group by statement that it is not allowed. Nor is an alias allowed.
Any suggestions as to how to get around this problem?
Thanks.
Leah

First of all, thank you all for your replies. I have still not succeeded.
The shortened code I am using now is:
select aa.threedigits ,v1.invoice_num invoice_num1
from apps.ap_invoices_v v1, apps.ap_invoices_v v2,
(select distinct apps.jafi_disco_utils_pkg.GetThreeLastDigits(invoice_num)
threedigits
from apps.ap_invoices_v v3
where v3.approval_status_lookup_code <> 'CANCELLED'
and v3.invoice_date between '06-JAN-2006' and '06-JAN-2006' ) aa
where v1.vendor_id = v2.vendor_id and
v1.approval_status_lookup_code <> 'CANCELLED' and
v2.approval_status_lookup_code <> 'CANCELLED' and
apps.jafi_disco_utils_pkg.GetThreeLastDigits(v1.invoice_num) =
apps.jafi_disco_utils_pkg.GetThreeLastDigits(v2.invoice_num)
and v1.invoice_date between '06-JAN-2006' and '06-JAN-2006'
and aa.threedigits = apps.jafi_disco_utils_pkg.GetThreeLastDigits(v1.invoice_num)
group by v1.invoice_num
having count(*) > 1
1) I limited the invoice date so as to shorten the query time.
2) If I omit the "group by" and "having" statements, here is a sample of the records that I get:
row threedigits invoice num
26     005     112/2005
27     005     112/2005
28     022     030A66D0022
29     185     4185
30     311     3315311
31     311     3315311
32     311     3315311
What I would like as my output are the rows above excluding row 28 & 29 which are single occurrences.
I am still getting an error in the group by statement and I don't know why.

Similar Messages

  • How to implement the Oracle Group by function in Crystal reports?

    Hi all,
    In SQL, for example we have a group function like:
    select  district,state, country, continent, sum(no.of people) from world.
    Now, How to implement this group function in crystal reports? Please advise.
    Thanks in advance..
    Regards,
    sriram

    Hi Vinay,
    Thanks for the prompt reply.
    In one of our report, we are supposed to perform group by for 14 columns to get sum of 3 columns and there by displaying 17 columns in the report.
    When we tried in crystal reports to implement this oracle group by functionality:
    1. We created 14 groups from the Insert->Group option.
    2. By performing this, we got 14 group sections vertically(one inside the other).
    3. Then we created the sum(15th column),sum(16th column), sum(17th column)  by Insert->Summary option.
    4. We suppresed all the group sections except for the last group.
    5. Then, dragged all the groups to the last group section along with the summary fields.
    This is how, we tried to acheive the oracle group by function in Crystal reports.
    Please advise, whether our approach is right. If not, please suggest the appropriate approach with a bit detailed explanation.
    Thanks,
    Sriram.

  • Add field group and Logical field group for ANLU

    Hi all,
    On my project, the table ANLU is containing many specifics fields.
    I would like to know how I could add a field group and logical field group corresponding to this specifics fields on ANLU, in order to be taking into account on my validation rule ?
    On the GGB0, Asset Accounting / master data, the check point includes the ANLU on the table fields. But, once my rule created, when I want to activate it on the TCODE OACV, the field group proposed don't include data from ANLU (only ANLA and ANLB)
    I found out the TCODE OAVM listing all different field linked to the field group. Does it possible to manage this view ?
    please help me !!

    Hi Rob,
    Can you tell me how can i solve this issue.
    Runtime Errors         MOVE_TO_LIT_NOTALLOWED
    Date and Time          09/11/2007 18:11:01
    Short text
        Assignment error: A constant was meant to be overwritten.
    Error analysis
        The field "<S1>" is to be assigned a new value although the field
        is partially or entirely protected against modifications.
        The following are protected against changes:
        - Character literals or numeric literals
        - Constants (CONSTANTS)
        - Parameters of the category IMPORTING REFERENCE for functions and
        methods
        - Untyped field symbols not yet assigned a field using ASSIGN
        - TABLES parameters if the actual parameter is protected against changes
        - USING reference parameters and CHANGING parameters for FORMs, if the
        actual parameter is protected against changes and
        - Accesses using field symbols if the field assigned using ASSIGN is
        protected (or partially protected, e.g. key components of an internal
        table with the type SORTED or HASHED TABLE) against changes
        - Accesses using references, if the field bound to the reference is
        protected (or partially protected) against changes
        - External write accesses to READ-ONLY attributes,
        - Content of a shared object area instance accessed using a shared lock
        (ATTACH_FOR_READ).
    Thanks
    Ashraf

  • Function Groups and Function Modules

    Hi,
    Can anyone give me the detail steps for creating Function Group and then from that function group creation of function module with example?
    Regards,
    Chandru

    Hi,
    Function Group creation -
           A function group is a program that contains function modules. With each R/3 system, SAP supplies more than 5,000 pre-existing function groups.
         In total, they contain more than 30,000 function modules. If the functionality you require is not already covered by these SAP-supplied function modules, you can also create your own function groups and function modules.
          We can put all the relevant function modules under one function group and all the global variables can be declared in this FG.
    FG Creation:
    1)     Function group can be created in SE80. There choose the 'Function Group' from the list of objects.
    2)    Then give a name for ur function group (starts with Y or Z) and press ENTER.
    3)   The click 'YES' in the create object dialog box and give a short desc. for this FG and save.
    Function Module:
                 A function module is the last of the four main ABAP/4 modularization units. It is very similar to an external subroutine in these ways:
    Both exist within an external program.
    Both enable parameters to be passed and returned.
    Parameters can be passed by value, by value and result, or by reference.
    The major differences between function modules and external subroutines are the following:
    Function modules have a special screen used for defining parameters-parameters are not defined via ABAP/4 statements.
    tables work areas are not shared between the function module and the calling program.
    Different syntax is used to call a function module than to call a subroutine.
    Leaving a function module is accomplished via the raise statement instead of check, exit, or stop.
    A function module name has a practical minimum length of three characters and a maximum length of 30 characters. Customer function modules must begin with Y_ or Z_. The name of each function module is unique within the entire R/3 system.
    Defining Data within a Function Module
    Data definitions within function modules are similar to those of subroutines.
    Within a function module, use the data statement to define local variables that are reinitialized each time the function module is called. Use the statics statement to define local variables that are allocated the first time the function module is called. The value of a static variable is remembered between calls.
    Define parameters within the function module interface to create local definitions of variables that are passed into the function module and returned from it (see the next section).
    You cannot use the local statement within a function module. Instead, globalized interface parameters serve the same purpose. See the following section on defining global data to learn about local and global interface parameters.
    Defining the Function Module Interface
    To pass parameters to a function module, you must define a function module interface. The function module interface is the description of the parameters that are passed to and received from the function module. It is also simply known as the interface. In the remainder of this chapter, I will refer to the function module interface simply as the interface.
    To define parameters, you must go to one of two parameter definition screens:
    1) Import/Export Parameter Interface
    2) Table Parameters/Exceptions Interface
    Then in the FM interface screen, give the following
    1) Import parameters
    2) Export parameters
    3) Changing parameters
    Then give
    1) Define internal table parameters
    2) Document exceptions
    You enter the name of the parameter in the first column and the attributes of the parameter in the remaining columns. Enter one parameter per row.
    Import parameters are variables or field strings that contain values passed into the function module from the calling program. These values originate outside of the function module and they are imported into it.
    Export parameters are variables or field strings that contain values returned from the function module. These values originate within the function module and they are exported out of it.
    Changing parameters are variables or field strings that contain values that are passed into the function module, changed by the code within the function module, and then returned. These values originate outside the function module. They are passed into it, changed, and passed back.
    Table parameters are internal tables that are passed to the function module, changed within it, and returned. The internal tables must be defined in the calling program.
    An exception is a name for an error that occurs within a function module. Exceptions are described in detail in the following section.
    Syntax for the call function Statement
    The following is the syntax for the call function statement.
    call function 'F'
        [exporting   p1 = v1 ... ]
        [importing   p2 = v2 ... ]
        [changing    p3 = v3 ... ]
        [tables      p4 = it ... ]
        [exceptions  x1 = n [others = n]].
    where:
    F is the function module name.
    p1 through p4 are parameter names defined in the function module interface.
    v1 through v3 are variable or field string names defined within the calling program.
    it is an internal table defined within the calling program.
    n is any integer literal; n cannot be a variable.
    x1 is an exception name raised within the function module.
    The following points apply:
    All additions are optional.
    call function is a single statement. Do not place periods or commas after parameters or exception names.
    The function module name must be coded in uppercase. If it is coded in lowercase, the function will not be found and a short dump will result.
    Use the call function statement to transfer control to a function module and specify parameters. Figure 19.9 illustrates how parameters are passed to and received from the function module.
    sample FM
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      I_INTERFACE_CHECK                 = ' '
      I_BYPASSING_BUFFER                = ' '
      I_BUFFER_ACTIVE                   = ' '
      I_CALLBACK_PROGRAM                = ' '
      I_CALLBACK_PF_STATUS_SET          = ' '
      I_CALLBACK_USER_COMMAND           = ' '
      I_CALLBACK_TOP_OF_PAGE            = ' '
      I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
      I_CALLBACK_HTML_END_OF_LIST       = ' '
      I_STRUCTURE_NAME                  =
      I_BACKGROUND_ID                   = ' '
      I_GRID_TITLE                      =
      I_GRID_SETTINGS                   =
      IS_LAYOUT                         =
      IT_FIELDCAT                       =
      IT_EXCLUDING                      =
      IT_SPECIAL_GROUPS                 =
      IT_SORT                           =
      IT_FILTER                         =
      IS_SEL_HIDE                       =
      I_DEFAULT                         = 'X'
      I_SAVE                            = ' '
      IS_VARIANT                        =
      IT_EVENTS                         =
      IT_EVENT_EXIT                     =
      IS_PRINT                          =
      IS_REPREP_ID                      =
      I_SCREEN_START_COLUMN             = 0
      I_SCREEN_START_LINE               = 0
      I_SCREEN_END_COLUMN               = 0
      I_SCREEN_END_LINE                 = 0
      I_HTML_HEIGHT_TOP                 = 0
      I_HTML_HEIGHT_END                 = 0
      IT_ALV_GRAPHICS                   =
      IT_HYPERLINK                      =
      IT_ADD_FIELDCAT                   =
      IT_EXCEPT_QINFO                   =
      IR_SALV_FULLSCREEN_ADAPTER        =
    IMPORTING
      E_EXIT_CAUSED_BY_CALLER           =
      ES_EXIT_CAUSED_BY_USER            =
      TABLES
        t_outtab                          =
    EXCEPTIONS
      PROGRAM_ERROR                     = 1
      OTHERS                            = 2
    IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    Example
    1  report ztx1905.
    2  parameters: op1 type i default 2,   "operand 1
    3              op2 type i default 3.   "operand 2
    4  data rslt type p decimals 2.        "result
    5
    6  call function 'Z_TX_DIV'
    7       exporting
    8            p1      = op1
    9            p2      = op2
    10      importing
    11           p3      = rslt.
    12
    13 write: / op1, '/', op2, '=', rslt.
    Regards,
    Shanthi.P
    Reward points if useful ****
    Edited by: shanthi ps on Jan 26, 2008 12:03 PM

  • Functionality field Usage type

    Hi,
    Could you tell me, what is functionality field Usage type. This field  is set to the solid, does not change. I has some important control function. What?
    Regards, Stenwa

    Hi Stenwa,
    The usage type is the main classification field for the rental objects. It controls functions such, as:
    1. The field stauts groups of your rental objects - which fields are available for input,etc.
    2. The screens you can maintain for the rental object
    3. Which area types are allowed, mandatory, etc.
    4. whether the rental object can be used commercially/non-commercially or both
    According to saphelp:
    "You can change the usage type of the rental unit as long as no active lease-out exists for a rental unit.
    You can only change the usage type of a rental unit with an active lease-out if the allocation of an internal usage type to the external usage type in Real Estate Customizing is not changed."
    Hope this helps!
    KR,Severina

  • Why cant I group by large fields, and why dont these print properly?

    I have a number of Crystal Reports fed by my database which has a table in it that stores Paths (to given files and locations). In SQL Server this path column is set to nvarchar(MAX).
    However, whenever I try to use this column in reports 2 things appear strange...
    1.) I can never group on this field (which I need badly to do) - it just never shows up in the Group Expert.
    2.) Whenever I use this field in a report and set the field to "Can Grow", it never prints anything beyond about 450 characters (and yes, we have some paths that go much longer than that) - in other words, although the "Can Grow" setting seems to work as the field will grow - it never prints anything beyond about 450 characters.
    What is happening with this? Any ideas anyone?
    (Please note....
    Crystal Version - 2008 with SP1
    Problem affects 48 reports - e.g. tried and tried to get this to work - wont...
    Please DO NOT respond to post in other forums - already have and would just like an answer)
    Thanks!

    Again, I appreciate the response and I mean no disrespect...
    But is there any way to get a definitive answer somewhere on these kinds of things?
    We cannot, as a company, keep "trying things" with Crystal Reports - we have been down this path now quite a few times and it seems we are the ones testing and debugging Crystal Reports for the SAP Company - which is driving our VP of Development nuts because I am taking sometimes days to figure out stuff that should be documented - as he says "especially for the price we paid for the product."
    If you dont know, okay, you dont know - and thats okay - but I cannot keep testing Crystal Reports for workarounds to simple things.  We are working on tight deadlines for major clients and more than once already, I have hosed up those deadlines with the simplest of things Crystal should be doing and documenting.
    So is there anywhere that I can search, find, beg for, buy, sell my children for - that would have this rather basic information?

  • Automatic assignment responsible group partner function of Activities

    Hi,
    I need help on below requirement>>
    Automatic assignment responsible group partner function of Activities when status is set to u201CIncorrectly Assignedu201D.
    Thanks

    you can check with order status badi
    BR
    Radek

  • Origin Group as Value field in COPA - Is that Possible

    Hello Gurus,
    The business requirement is to see all the Origin Groups as Value fields in COPA - Is that Possible? If Yes, Please suggest me the steps to follow.
    Thanks a lot for your time.
    Regards,
    PM

    Hi Praveen
    Origin group cant be a Value Field.. It can be a Characteristic...
    Try with these 2 options
    1. KEA5 - Click on Create/Change a new Char and Try to create it with reference from table MBEW... If this is allowed, you will be able to plug in the Field Origin group in yur COPA data structure... regenerate your op concern after this
    2. If (1) is not allowed, then create a WW char and write a derivation rule in KEDR with ref to Table LOOKUP and use table MBEW
    Regards
    Ajay M

  • Sort order for group by functions

    I have table TAB1(notenum number, linenum number, linetext varchar2(100)).
    Each note can have multiple lines of text. Eg data
    NOTENUM     LINENUM     LINETEXT
    1     1     THIS IS LINE1.
    1     2     THIS IS LINE2.
    2     1     THIS IS LINE1 OF NOTE2.
    2     2     THIS IS LINE2 OF NOTE2.
    I need the text of lines of the most recent note (max notenum)
    <Note>THIS IS LINE1 OF NOTE2. THIS IS LINE2 OF NOTE2</Note>.
    I have a query like this
    SELECT XMLAGG(XMLPARSE(CONTENT LINETEXT WELLFORMED))
    FROM TAB1
    GROUP BY NOTENUM
    ORDER BY NOTENUM DESC
    Above query would return the text of all lines concatenated for each note and the first row would be the one with highest notenum value.
    My problem is that concatenation of the LINETEXT should happen in ascending order of LINENUM. Since LINENUM is not in GROUP BY clause I cannot specify it in ORDER BY.
    How can I specify to XMLAGG (for that matter any group by function) to concatenate text in a specific order.
    I hope I was able to explain my problem clear enough for somebody to help.
    thanks for all the help
    Message was edited by:
    user448703
    Message was edited by:
    user448703

    Never mind. I just found out that XMLAGG function has the option to specify ORDER BY. I think that will work.

  • Group by function use in sql

    I want to get an output using group by function of there is no data in the table to display a particular value
    for eg:
    SELECT TRUNC(updated_date) DATE1 , COUNT(1) COUNT FROM table
    where TRUNC(updated_date) >=TRUNC(SYSDATE-18) AND TRUNC(updated_date) <=TRUNC(SYSDATE)
    GROUP BY TRUNC(updated_date)
    ORDER BY TRUNC(updated_date) DESC;
    DATE1 COUNT
    6/16/2012 14208
    6/15/2012 307825
    6/14/2012 172988
    6/6/2012 138790
    6/5/2012 167562
    6/4/2012 51870
    6/2/2012 130582
    6/1/2012 239806
    But i need the missed out date i.e 6/3/2012 - 0, 6/7/2012 - 0 to be displayed since there is no data on the repective dates.

    Hi,
    You can only display things that are in a table (or result set, but from now on, I'll just say table), or that can be derived from a table. If you want to display dates that are not in your table, then you have to get them from another table, or derive them from some table.
    Some people actually keep tables of possible dates for queries like this. In this case, all you need is a table of the last 19 dates, ending with today. That's easy to derive from dual:
    WITH     all_dates     AS
         SELECT     TRUNC (SYSDATE)     - LEVEL     AS date1
         ,     TRUNC (SYSDATE) + 1 - LEVEL     AS date2
         FROM     dual
         CONNECT BY     LEVEL <= 19
    SELECT    a.date1
    ,        COUNT (x.updated_date)     AS count
    FROM                all_dates     a
    LEFT OUTER JOIN    table_x     x  ON     x.updated_date     >= a.date1
                                AND     x.updated_date     <  a.date2
    GROUP BY  a.date1
    ORDER BY  a.date1
    ;If you'd care to post CREATE TABLE and INSERT statements for some sample data, and the results you want from that data, then I could test this.

  • How to make fields in field group as text fields in ABAP query

    Hi friends,
    I a have a ABAP query 85 corresponding to infoset A205,
    there is a field group in the infoset A205 and it contains some fields
    but some of the fields are made as text fields ................i want to know how to make these fields in
    the field group as text fields.
    there is a small icon  " T " on the field when it is made as a text field .
    Please help me
    Thanks & Regards

    Hi,
    IF you can specify which Field Catalog then it will be useful for us to provide appropriate answer.
    1. For Customer Master
    IMG> Financial Accounting New> Acs Recev and Acs Payable --> Customer Accounts --> Master Data --> Preperation of creating customer master Data --> Define Account Groups with screen layout (customers)
    In that you can create your own account group, and click Details Screen.
    There will Field Status header within that are listed three main areas
    General data
    Company code data
    Sales data
    When you double click these lines it will take you into "Status Group" Overview. Wherein under "Select Group" are listed fields Address, communiucation.... Double click on one group , you will bet aken into the group field wherein you will find 4 colums with indicators assigned to it. ( Suppress, Req. Entry, Opt Entry, Display) you can choose the required option. "Req. Entry" against the field. Click save after you complete your selections.
    2. Similarly you can do for Material Master in
    IMG --> Logistics General --> Material Master --> Field Selection --> Maintain Field Selection for Data Screens
    But be careful when you do it for material master as it is cuts across all the modules...
    Regards
    Sathya

  • Help in group by function

    Hi All
    very simple one but i just confused by it . i just want to display the rows in group by function .
    example
    SQL> select user_full_name,last_login_date,email_address from comit_user group by company_code
    its giving an error .
    could some one please help me in this .
    thanks in advance .

    Hi there,
    Group by is used with group functions such as SUM, AVG, MAX, MIN, etc
    eg. select job, sum(sal) from emp group by job;
    JOB SUM(SAL)
    ANALYST 6000
    CLERK 4150
    MANAGER 8275
    PRESIDENT 5000
    SALESMAN 5600
    In your query, it looks like you need to use ORDER BY instead
    select user_full_name,last_login_date,email_address from comit_user
    ORDER BY company_code
    Regards,
    John

  • To fetch data using group by function

    Hi Guys,
    I am having a table where it holds data with value with zero in one of the column and i need to fetch the records from the table using group by function but to display all the records if zero occurs in my table
    for eg
    table1
    id,customer_name,country
    0     sam     aus
    1     peter     ind
    1 peter    ind
    0 samy     us
    0 rayan     nz
    if i use select count(*),id from table1 group by id
    i will get
    count(*),id
    3-0
    1-2
    but wat i need is like below
    0     sam     aus
    0 samy     us
    0 rayan     nz
    2 peter ind
    whenever zero is occurring i need to display all the records but group by should work for non zero records

    The simplest way would be to have two queries and UNION them together. For example:
    WITH test_data AS
    ( SELECT 0 AS id, 'sam' AS customer_name, 'aus' AS country FROM DUAL UNION ALL
      SELECT 1 AS id, 'peter' AS customer_name, 'ind' AS country FROM DUAL UNION ALL
      SELECT 1 AS id, 'peter' AS customer_name, 'ind' AS country FROM DUAL UNION ALL
      SELECT 0 AS id, 'samy' AS customer_name, 'us' AS country FROM DUAL UNION ALL
      SELECT 0 AS id, 'rayan' AS customer_name, 'nz' AS country FROM DUAL
    SELECT cnt
         , customer_name
         , country
    FROM   ( SELECT id
                  , customer_name
                  , country
                  , COUNT(*) OVER (PARTITION BY id) AS cnt
                  , ROW_NUMBER() OVER (PARTITION BY id ORDER BY id) rn
             FROM   test_data
             WHERE  id != 0
    WHERE  rn = 1    
    UNION
    SELECT id
         , customer_name
         , country
    FROM   test_data
    WHERE  id = 0
    This gives the following results:
           CNT CUSTO COU
             0 rayan nz
             0 sam   aus
             0 samy  us
             2 peter ind

  • How to Use a Group by Function

    Hi Gurus,
    I have Requirment where i need to use the group by function to one column
    below is my query , can anyone help how to use the group by for the column OCCASIONALS_QT_STATUS.
    below is giving me the error not a group by expression
    select distinct source_id,OCCASIONALS_QT_STATUS,
    (SELECT sum(head_count)
    FROM gen_dcsf_occasionals_count
    where OCCASIONALS_QT_STATUS = 'QTS'
    and source_id = gdoc.source_id
    ) OccasionalsQTS,
    (SELECT sum(head_count)
    FROM gen_dcsf_occasionals_count
    where
    OCCASIONALS_QT_STATUS = 'NOTQTS'
    and source_id = gdoc.source_id
    ) OccasionalsNOTQTS,
    (SELECT sum(head_count)
    FROM gen_dcsf_occasionals_count
    where
    OCCASIONALS_QT_STATUS = 'NTKNWN'
    and source_id = gdoc.source_id
    ) OccasionalsNOTKNWN
    from gen_dcsf_occasionals_count gdoc group by OCCASIONALS_QT_STATUS;
    any inputs on this is highly appreciable
    Thanks in advance

    909577 wrote:
    Hi Gurus,
    I have Requirment where i need to use the group by function to one column
    below is my query , can anyone help how to use the group by for the column OCCASIONALS_QT_STATUS.
    below is giving me the error not a group by expression
    select distinct source_id,OCCASIONALS_QT_STATUS,
    (SELECT sum(head_count)
    FROM gen_dcsf_occasionals_count
    where OCCASIONALS_QT_STATUS = 'QTS'
    and source_id = gdoc.source_id
    ) OccasionalsQTS,
    (SELECT sum(head_count)
    FROM gen_dcsf_occasionals_count
    where
    OCCASIONALS_QT_STATUS = 'NOTQTS'
    and source_id = gdoc.source_id
    ) OccasionalsNOTQTS,
    (SELECT sum(head_count)
    FROM gen_dcsf_occasionals_count
    where
    OCCASIONALS_QT_STATUS = 'NTKNWN'
    and source_id = gdoc.source_id
    ) OccasionalsNOTKNWN
    from gen_dcsf_occasionals_count gdoc group by OCCASIONALS_QT_STATUS;
    any inputs on this is highly appreciable
    Thanks in advanceFor your own sanity, you should format your code to make it more readable
    For the sanity of those from whom you seek help, you should preserve that formatting with the code tags:
    select
         distinct source_id,
         OCCASIONALS_QT_STATUS,
         (SELECT
               sum(head_count)
          FROM
               gen_dcsf_occasionals_count
          where
               OCCASIONALS_QT_STATUS = 'QTS'   and
               source_id = gdoc.source_id
         ) OccasionalsQTS,
         (SELECT
              sum(head_count)
         FROM
              gen_dcsf_occasionals_count
         where
              OCCASIONALS_QT_STATUS = 'NOTQTS' and
              source_id = gdoc.source_id
         ) OccasionalsNOTQTS,
         (SELECT
              sum(head_count)
         FROM
              gen_dcsf_occasionals_count
         where
              OCCASIONALS_QT_STATUS = 'NTKNWN' and
              source_id = gdoc.source_id
         ) OccasionalsNOTKNWN
    from
         gen_dcsf_occasionals_count gdoc
    group by
         OCCASIONALS_QT_STATUS;

  • Group by function in a measure object

    Hi All,
        I am trying to create a measure in universe which is the sum of ticket amount group by country. like,
    sum(Payments.Ticket_Amount) group by country name. When i place this measure in a report group footer it should display the sum to that particular group. But it is not working.
    Could anybody help me how to write a group by function to create a measure.
    Thanks,
    swati.

    Hi swati.
    You don't need to write the GROUP BY statement at the universe level.
    The universe knows that aggregate functions require group by statements and will group the aggregate measure objects by whatever dimension objects are included in the query. If you have a measure object that is not based on an aggregate but has a projection of Sum, it will only be aggregated at the report level once the data has been returned by the query.
    Measure: sum(sales_fact.value)
    Measure: sales_fact.price
    Dimension: country_dim.country
    This would generate SQL along the lines of:
    SELECT sales_fact.price, country_dim.country, sum(sales_fact.value)
    FROM sales_fact, country_dim
    WHERE sales_fact.country_key = country_dim.country_key
    GROUP BY sales_fact.price, country_dim.country
    Hope that clears it up for you.
    Regards,
    Mark

Maybe you are looking for

  • Articles on Printing in VC7.0

    I was wondering if anyone had some links to solutions of printing the results of a VC application and it looksing decent.

  • Cant get rid of TV programmes of my 3GS

    I have some TV programmes on my iPhone 3GS I cant seem to delete them and when I sync to iTunes it keep transferring the TV programmes into my iTunes folder can anybody please tell me how to delete these TV programmes because they're filling up my me

  • E71 wifi and maps issues.

    Does anyone have this problem and know how to fix it? the problem i have is trying to save the maps through wifi (i dont want to use packet data, dont have a plan, although it works and im gonna regret fiddling with it when i get my bill).... it just

  • Reg : grandtotals in alv's

    hi friends, i am trying to display the grand total using do_sum in  fieldcat.its working fine. my doubt is ... what is the field  where this grandtotal be captured ? thanks, urmila.T

  • I have protools 8 software for my osx and im looking to get osx lion . will it still work ?

    i have protools 8 software for my osx and im looking to get osx lion . will it still work ?