Condition - group by

Good Morning Everyone,
We wrote 50 lines according to Business Rules and every thing are working fine.
The seniors want to add an condition, we added in Main WHERE
AND (Table9.OK_YN Not Equal To 'Y')
We used Not Equal To single row comparison operator. We should not post it in here.
So far so good!
They wish to add another condition and group by to separate report.
We have challenges and we need your help as usual.
If you have expereinces, please share for us.
Thanks in advance,
NY
Edited by: New Yorker on Aug 24, 2010 7:47 AM

Thank Andreas Weiden,
SELECT DISTINCT R.CLASS_ID,LF.LOC_IND,U.LNAME, AF.A_CODE
FROM COURSES CO, USERS U, CLASSES C, REGISTRATIONS R,
CLASS_DETAILS CD, LOCATIONS_RF LF, FORMATS_RF FF, >SPONSORS_RF SF, B_RF BF, A_RF AF
WHERE ( (R.USER_ID = U.USER_ID) AND (R.CLASS_ID = C.CLASS_ID)>AND (CD.LOC_ID = LF.LOC_ID) AND (R.CLASS_DET_ID = CD.CLASS_DET_ID)
>AND (CD.FORMAT_ID = FF.FORMAT_ID) AND (C.COURSE_ID = CO.COURSE_ID)
>AND (C.SPONSOR_ID = SF.SPONSOR_ID) AND ( U.BARG_ID = BF.BARG_ID )
>AND ( U.A_ID = AF.A_ID )
>And (C.CLASS_ID = 52) )
We saw expected output.
We would like to add:
If LF.LOC_IND is not equal to Y, we would like to gorup by AF.A_ID.
We assume that AND (LF.LOC_IND< not equal to >'Y') put in WHERE.
( We used not equal single-row query operator but it did not show in here. So, < not equal to > for description purpose only)
If you have any more questions for us, please let us know.
Thanks for all again,
NY

Similar Messages

  • Conditional GROUP BY

    Hi
    I need a SQL report to conditionally display fields based on the value of a bind variable.
    I can achieve this via the interactive reports feature conditional display but I need to remove the GROUP BY for that field at the same time.
    How can I have a conditional GROUP BY clause based a value of a bind variable?
    Regards
    Adam

    >
    If :SHOW_FIELD3 was NOT 'TRUE' then what would
    the statement GROUP BY??? ...The statement would group by field1 and field2 in that case.
    test@ora>
    test@ora> var FIELD1_SHOW varchar2(5)
    test@ora> var FIELD2_SHOW varchar2(5)
    test@ora> var FIELD3_SHOW varchar2(5)
    test@ora>
    test@ora> exec :FIELD1_SHOW := 'TRUE';
    PL/SQL procedure successfully completed.
    test@ora> exec :FIELD2_SHOW := 'TRUE';
    PL/SQL procedure successfully completed.
    test@ora> exec :FIELD3_SHOW := 'FALSE';
    PL/SQL procedure successfully completed.
    test@ora>
    test@ora> --
    test@ora> with t as (
      2    select 'true' as f1, 'true' as f2, 'true' as f3, 1 as num from dual union all
      3    select 'true', 'true',  'true',  2  from dual union all
      4    select 'true', 'false', 'true',  9  from dual union all
      5    select 'true', 'false', 'true',  10  from dual union all
      6    select 'true', 'true',  'false', 20 from dual union all
      7    select 'true', 'true',  'false', 21 from dual)
      8  --
      9  select
    10    decode(:FIELD1_SHOW, 'TRUE', f1) as f1,
    11    decode(:FIELD2_SHOW, 'TRUE', f2) as f2,
    12    decode(:FIELD3_SHOW, 'TRUE', f3) as f3,
    13    sum(num) as total
    14  from t
    15  group by decode(:FIELD1_SHOW, 'TRUE', f1),
    16           decode(:FIELD2_SHOW, 'TRUE', f2),
    17           decode(:FIELD3_SHOW, 'TRUE', f3);
    F1   F2    F3         TOTAL
    true false               19
    true true                44
    test@ora>
    test@ora>which is the same as:
    test@ora>
    test@ora> --
    test@ora> with t as (
      2    select 'true' as f1, 'true' as f2, 'true' as f3, 1 as num from dual union all
      3    select 'true', 'true',  'true',  2  from dual union all
      4    select 'true', 'false', 'true',  9  from dual union all
      5    select 'true', 'false', 'true',  10  from dual union all
      6    select 'true', 'true',  'false', 20 from dual union all
      7    select 'true', 'true',  'false', 21 from dual)
      8  --
      9  select f1, f2, sum(num) as total
    10  from t
    11  group by f1,f2;
    F1   F2         TOTAL
    true false         19
    true true          44
    test@ora>
    test@ora>with the exception of field3 being SELECTed and shown as NULL.
    isotope

  • Condition Group Routines

    Hello,
    I was asked by my functional analyst to implement the ABAP code for the following scenario:
    A header pricing condition type's amount, say ZHDR, needs to be populated by the largest amount found in certain item pricing condition type (say all ZDTL conds) on all items within a sales order.
    Is the solution for this condition group routines?
    Thanks,
    John

    Hi,
    This depends on your requirement. If you have defined the condition at the material pricing group level, then no need. The routine is used only if you want the condition to be read differently for each item (with the scale base value being total of all the items).
    You can find some help in the below link:
    http://help.sap.com/saphelp_erp2005/helpdata/en/de/7a8534c960a134e10000009b38f83b/frameset.htm
    There are some helpful SAP Notes if you need further clarifications:
    39034     Group condition routine
    854978     Function of cumulated scale base values (in SD)
    109708     Scale processing for group conditions
    Hope this helps.
    Regards
    Nikhilesh

  • Condition Groups in Contracts

    Hi,
    Is it possible to default few condition types in contracts transaction types in CRM under the Sales Agreeement tab?
    The issue is that, there is a condition group assiged to the transaction type instead of pricing procedure.
    Can some one help me to get the some default condition types?
    Regards
    Kamalesh

    Hi,
    Did n't really get the scenerio & problem? could you elaborate little more? What conditions & condition group is being used under the tab you mentioned?
    you can control the customizing of conditions & condition group visible in a TR in SPRO. Try following:
    1. check condition group being used to the application SAP CRM in SPRO > Customer Relationship Management> Master Data> Products> Special Settings for Sales Operations--> Assign Condition Group to Application CRM
    2.Assign the condition types in your pricing procedure to the above condition group by choosing SPRO>Customer Relationship Management> Master Data --> Conditions and Condition Technique --> Condition Technique: Basics Create Maintenance Group
    Let me know if this works....!!
    Best Regards,
    VIshant Jain

  • Automatic determination of condition group

    Hi
    My client has the following requirement:
    - For 3rd party items, in few situations we might have to supply the items immediately.
    - In such situations we request our supplier to supply the item directly to the customer (instead of bringing the item into our plant and then shipping)
    - In the existing sales orders we change the item category of the item from ZTAN to ZTAS (3rd party item).
    Customer wants to have automatic determination of the condition group 2 field at the item level (to some specified CG2 values) whenever we have the change in the item category.
    Let me know how we can do this.
    Regards
    Jagadish

    Hi Jagadish,
    The field Condition group 2 will be depend upon the Customer not based on the Material or Item or itemcategory,
    So I dodn't think system will change the data in this field when you change itemcategory alone.
    If you change the customer it will change accordingly
    I hope it will help you,
    Regards,
    Murali.
    Edited by: Murali Mohan.Tallapaneni on Jul 12, 2008 6:37 AM

  • Condition Groups in Purchase info record

    Hi SAP Folks
    Can you please in undertsanding the usage of the Field : Condition Groups in Purchase info record .
    How can this be used and what are the required set up to be done  in the system.
    We are SAP ECC 6.0
    Thanks for the help.
    Achu

    Hi,
    Click F1 on field Cond. Grp which gives the infomation about the Condition groups.
    Check  links : http://help.sap.com/saphelp_47x200/helpdata/en/75/ee1fa755c811d189900000e8322d00/frameset.htm
    Condition group comes under strategic sourcing and it is used to group together vendor  & mass changes for vendor masters.
    e.g to change tax condition for certain group. Check the T-code MEKG.
    Hope it will help U...
    Regards
    Vikrant

  • Conditional GROUP BY clause

    Hi,
    I have four columns in group by clause. I want to add conditional group by clause.
    Case 1 : If one of the  column's value is null, I don't want to include it in group by clause. Means, Now GROUP BY clause will have only 3 columns.
    Case 2 : If not null, then GROUP BY clause with all four columns.
    Please help me out on this.
    Thanks in advance.  

    Hi
    I think it won't matter, all group functions by default ignore NULLs so your result won't differ.
    select  dept, loc, sum(sal)
    from (
    select 'A' emp , 1 dept , 'P' loc , 100 sal from dual union all
    select'B',1,'P',200 from dual union all
    select'C',2,'P',300 from dual union all
    select'D',2,'P',400 from dual union all
    select'E',3, 'P',500 from dual union all
    select'F',3, 'P',600 from dual union all
    select'G',4, 'Q',700 from dual union all
    select'H', null,'Q' , 1000 from dual union all
    select'I',null ,'Q', 2000 from dual union all
    select 'J' ,null, 'Q',300 from dual)
    group by dept,loc;
    Output
    DEPT      LOC      SUM(SAL)
    1                P      300
    2                P      700
    3                P      1100
                    Q      3300
    4                Q      700
    Now by doing grouping only for NOT NULL values,
    select dept,loc, sum(sal)
    from (
    select 'A' emp , 1 dept , 'P' loc , 100 sal from dual union all
    select'B',1,'P',200 from dual union all
    select'C',2,'P',300 from dual union all
    select'D',2,'P',400 from dual union all
    select'E',3, 'P',500 from dual union all
    select'F',3, 'P',600 from dual union all
    select'G',4, 'Q',700 from dual union all
    select'H', null,'Q' , 1000 from dual union all
    select'I',null ,'Q', 2000 from dual union all
    select 'J' ,null, 'Q',300 from dual)
    where dept is not null          --------------NOT NULL Condition
    group by dept, loc;
    Output
    DEPT     LOC      SUM(SAL)
    1           P           300
    2           P           700
    3           P           1100
    4           Q           700
    Now by doing grouping only for NULL values,
    select dept,loc, sum(sal)
    from (
    select 'A' emp , 1 dept , 'P' loc , 100 sal from dual union all
    select'B',1,'P',200 from dual union all
    select'C',2,'P',300 from dual union all
    select'D',2,'P',400 from dual union all
    select'E',3, 'P',500 from dual union all
    select'F',3, 'P',600 from dual union all
    select'G',4, 'Q',700 from dual union all
    select'H', null,'Q' , 1000 from dual union all
    select'I',null ,'Q', 2000 from dual union all
    select 'J' ,null, 'Q',300 from dual)
    where dept is null               --------------NULL Condition
    group by dept, loc;
    Output
    DEPT      LOC         SUM(SAL)
                    Q           3300
    The output is same for both the conditions.

  • Condition group in Sales order

    Hi Experts,
    I need help in maintaining the <b>condition group 1</b> value in tab <b>additional dataA</b>  in sales order item level. Right now we are getting the values based on the sold to customer of the sales order but we need it based on the ship to customer.
    Even a way to approach it will be really appreciated.
    Thanks,
    Surya

    Hi,
    You can proceed as follows:
    Procedure for copying customer master fields to a sales document
    Copying customer master fields to a sales document is carried out in two steps:
    1. A field in the customer master table (KNA1 or KNVV) is first copied by INCLUDE (KUAGVZ, KUWEVZ, KURGVZ and KUREVZ) to the sold-to party, ship-to party or payer view (KUAGV, KUWEV, KURGV or KUREV). A value is assigned to the field via a user exit (V05...).
    2. The field is copied to the sales order table (VBAK, VBKD or VBAP) from the respective customer view (KUAGV, KUWEV, KURGV or KUREVZ). A value is assigned to the field via a user exit in program MV45AFZZ (USEREXIT_MOVE_...).
    In your case it will be:
    The following communication structures are relevant for using customer master record fields in SD documents:
    KUWEV (Ship-to party view of customer master record)
    Transport from customer view to the sales document table
    USEREXIT_MOVE_FIELD_TO_VBAP
    Regards
    Shounak

  • Increasing condition groups for a customer

    Hi all,
    There is a business requirement wherein a customer needs to be associated with more than 5 condition groups configurable in customer master data under extra (additional data) settings.  Since SAP has a limitation of  only 5 condition groups, I am not sure how can this requirement be met without undertaking a Z enhancement. Is there any other way/method in SAP by which this objective can be achieved?
    Would be greatful if anyone could share their experience on the same.
    Thanks
    Aashish

    hi,
    that means there are only 5 customer groups in standard SAP.
    if you want to increase you can do it technically only by capturing the program name.
    SAPLV02Z, screen number 0200.
    i think you have to for screen modification.
    other than this there is no any alternative.
    balajia

  • Please provide Solution for Customer Condition Group when defining 2 Chrt's

    Dear Guru's,
    Please provide Solution for Customer Condition Group when defining 2 Charecters or 2 digits.
    I have Completed all possible Combinations like AA,BA,1A,A1,01 to 99 etc.. Total Enteries reach upto 1200+ so I am unble to find no more Combinations( without Special Characters & no chance to increase other than 2 Char/digt)..
    Any body Suggest me any Good Combinations or Proper Alternative....
    Thanks,
    Panduranga

    Hi panduranga
    A Customer Condition Group is maintained in only 2 digits .If you want to go for more than 2 digits then you need to take the help of ABAP'er and you need to go for enhancement
    Regards
    Srinath

  • Customer condition group 1 - 5 on VF02/VF03???

    Hi folks
    In the invoice position table - VBRP - we have the Customer condition group fields (1-5) But unfortunally I can't see them in the trabnsaction VF02/VF03!
    How or what to do?
    Best regards
    Carsten

    Hi
    At item level, you have see the additional data of the reference sales order at the item level.. You can see that in Additional Data1 of the item.
    Reward if this helps.

  • Use sequence for dynamic conditional grouping

    Hi experts,
    I have a simple(?) task - I want to number (assign) some groups (increasing group number) based on a condition.
    Here an example: create numbered groups based on department number (actual the same grouping)
    create table emp as
    select * from scott.emp;
    CREATE SEQUENCE group_no;
    SELECT group_no.NEXTVAL FROM DUAL;
    SELECT group_no.CURRVAL FROM DUAL;
    /* automatic grouping - NOT WORKING!!!! */
      select ename, deptno, deptno_next, deptno_prev,
       case when (deptno_next > deptno) then group_no.nextval else 1 end grp
        from
          (select ename, deptno,
                  lead(deptno) over (order by deptno) deptno_next,
                  lag(deptno) over (order by deptno) deptno_prev
          from emp
    PROBLEM:
    It seems the sequence is increased, even when the condition for a new number is not met!
    NAME      DEPTNO                 DEPTNO_NEXT            DEPTNO_PREV            GRP                   
    CLARK      10                     10                                            1                     
    KING       10                     10                     10                     1                     
    MILLER     10                     20                     10                     130                   
    JONES      20                     20                     10                     1                     
    FORD       20                     20                     20                     1                     
    ADAMS      20                     20                     20                     1                     
    SMITH      20                     20                     20                     1                     
    SCOTT      20                     30                     20                     135                  
    WARD       30                     30                     20                     1                     
    TURNER     30                     30                     30                     1                     
    ALLEN      30                     30                     30                     1                     
    JAMES      30                     30                     30                     1                     
    BLAKE      30                     30                     30                     1                     
    MARTIN     30                                            30                     1instead of else 1 I will use group_no.currval (same group number, when not changing department). I know, I need to cover the previous number as well, but I made it simple, because the problem here seems to be the sequence...
    Looking forward to your support :-)
    Duik
    Edited by: user10939560 on 08.10.2012 07:42
    Edited by: user10939560 on 08.10.2012 07:44
    Edited by: user10939560 on 08.10.2012 07:45
    Edited by: user10939560 on 08.10.2012 07:48
    Edited by: user10939560 on 08.10.2012 07:49

    Yes, your observation is correct.
    You cant use a sequence this way.
    May be the below gives you a hint to achieve your goal.
    select
    ename
    ,empno
    ,deptno
    ,case
    when lag(deptno, 1, deptno) over (order by deptno) = deptno
    then deptno
    else 30*deptno
    end mark
    from emp
    order by deptno
    ENAME     EMPNO     DEPTNO     MARK
    clark     7782     10     10
    miller     7934     10     10
    KING     7839     10     10
    ford     7902     20     600
    scott     7788     20     20
    jones     7566     20     20
    SMITH     7369     20     20
    adams     7876     20     20
    WARD     7521     30     900
    martin     7654     30     30
    ...Example with consecutive ordering
    select
    ename
    ,empno
    ,deptno
    ,sum(grp) over (order by deptno) grp
    from (
    select
    ename
    ,empno
    ,deptno
    ,case
    when lag(deptno, 1, deptno) over (order by deptno) = deptno
    then 0
    else 1
    end grp
    from emp
    order by deptno
    ENAME     EMPNO     DEPTNO     GRP
    clark     7782     10     0
    miller     7934     10     0
    KING     7839     10     0
    ford     7902     20     1
    scott     7788     20     1
    jones     7566     20     1
    SMITH     7369     20     1
    adams     7876     20     1
    WARD     7521     30     2
    martin     7654     30     2
    ...Edited by: chris227 on 08.10.2012 08:08
    consecutive ordering

  • Conditional Grouping

    I want the user to be able to choose between two formats: Group by Order.Date or No Grouping. Conditional suppression of the group does not satisfy this requirement; the group header is not visible but the groupings are still present in the body of the report.
    I tried writing a formula, hoping to base the group on that formula. But the formula generates an error:
    If {?pmDate} = True Then
        Formula = {Table.Date}
    Else
        Formula = AllDatesToToday    'Error - Date required
    End If
    I think the error is the result of one or even two related problems:
    The formula evaluates to different date types.
    The Else clause evaluates to a DateRange (not allowed).
    I am stuck. Is there a way to create a user driven parameter that determines whether a particular group will be used or not.
    Art

    The result of the IF part and the ELSE part should be of the same data type, hence the error.
    I do not think you can either group on a date or no grouping at all.  However, here is an idea.
    1. Create a parameter of type string with two static values of YES and NO and name the parameter "Group on Order Date?".
    2. Group on Order.Date choosing the option of "For Each Day" or for each second as the requirements dictate.
    3. Click on Group Expert and then choose the order.date and then click on "Options".
    4. In the pop-up check the box next to 'Use a Formula as a Group Sort Order' and click on the x+2 button.
    5. In the formula workshop window type:
    if {?My Parameter} = 'yes' then crascendingorder else croriginalorder;
    If the user chooses YES to the parameter, then the report will be grouped by order.date in Ascending Order and if the user chooses NO then the report is still grouped by the order.date but is listed in the original order (which will be in whatever order they are read and thus displaying some randomness).
    Edited by: Sanjay Kodidine on Aug 25, 2009 9:45 AM

  • BAPI_SALESORDER_SIMULATE Customer condition group 1

    I am trying to use the BAPI_SALESORDER_SIMULATE to determine price and need the VBKD-KDKG1 to determine pricing. Where is this value populated in the BAPI? It in not in the header CUST_GRP1.
    Thank you,

    Hi,
      I hope BAPISDHEAD-CUST_GROUP is the right one which you can find in the header only.
    Thanks
    Satyasuresh Donepudi

  • Group conditions in price conditions

    In a pricing condition, group conditions may be checked off to include in a group.
    How specifically do they belong to a group as per the requirements? What group are they referring to?
    "Group condition
    Indicates whether the system calculates the basis for the scale value from more than one item in the document.
    Use
    For a group condition to be effective, the items must belong to a group. You can freely define the group to meet the needs of your own organization. The items can, for example, all belong to the same material group.
    Example
    A sales order contains two items. Both items belong to the material group 01.
    Material Quantity Material group
    A 150 01
    B 100 01
    The group condition indicator is set in the definition of the condition type for material group discounts. The condition record for material group 01 includes the following pricing scale:
    Scale quantity Discount
    from 1 pc -1%
    from 200 pc -2%
    Neither item alone qualifies for the 2% discount. However, when the items are combined as part of a group condition, the combined quantity creates a basis of 250 pieces. This basis then exceeds the scale value of 200 pieces, which is necessary to qualify for the higher discount."

    Hi Anabela
    New groups can be defined in VOFM if required, in addition to those supplied by SAP.
    A simple example of a group would be the pre-defined group 1 - All items.
    This group can be used for instance to define a value based discount which you want to apply to all items in the order, based on the total order value.  Group conditions are similar to header conditions, but have the advantage that they can be automated with condition records, which is not possible for header conditions.
    So, you would set up a group condition, possibly with scales, to re-ward customers for larger orders.  Because it is a group condition, the discount would be based on the total order value and then applied to all of the items in the order.
    Another option would be to use group 3 - material pricing group.  This would let you apply the group condition to all of the materials in a pricing group.  For instance, if you wanted to set up scales for similar materials so that your customer gets the same price breaks across a number of order lines, regardless of the mix of materials bought.
    HTH
    James

Maybe you are looking for

  • Relative paths for images upset by forwarding requests

    Hello World.           I am using a web app deployed in Weblogic 5.1 with service pack 8.           I have hit a problem which puzzles me. When I forward a request from           one JSP to another (say from A to B) the web server seems to take the  

  • Loads using DTP - manual update possible?

    Hi, I have a question regarding loads done using DTP in BW 7.0. In 3.X loads using infopackages, sometimes a data package will get runtime errors such as DBIF_RSQL_SQL_ERROR (deadlocks). Usually, we would change the status to red and do a manual upda

  • I may be crazy

    I may be crazy but when I listen to the audio in FC it seems like it sounds pretty good but then I send it to Soundtrack to touch up and it seems like the background noise and noises are so much worse. Is there a reason for this? Or is it just in my

  • How to edit  a site made with iWeb?

    I made a simple site with pictures with iWeb 08, I would like to edit some text and also to add more pictures, and 'easy' solution would be to add the new pictures edit the text, delete the 'old' site and upload to new one. www.fuentebonita.com Is th

  • Using web content with parameter

    Hi, I found the nice shuffle letters example in the DPS Tips and I like to use it in an project. It works fine and I extended it for use with a parameter. I like to set an URL like "shuffle/index.html?text=Display%20this%20text" and the shuffle scrip