Data filtering base on condition

hi all, i need some help filtering the data below
WITH data1 AS
SELECT 1 pid, 'BS' typecd, 'SECC' category FROM dual UNION ALL
SELECT 1 pid, 'BS' typecd, 'SECCA' category FROM dual UNION ALL
SELECT 2 pid, 'PET' typecd, 'SECC' category FROM dual UNION ALL
SELECT 2 pid, 'BS' typecd, 'PRINC' category FROM dual UNION ALL
SELECT 3 pid, 'CAT' typecd, 'PRINC' category FROM dual UNION ALL
SELECT 3 pid, 'CAT' typecd, 'AC' category FROM dual UNION ALL
SELECT 3 pid, 'PET' typecd, 'AC' category FROM dual UNION ALL
SELECT 4 pid, 'PET2' typecd, 'SECC' category FROM dual UNION ALL
SELECT 4 pid, 'PET2' typecd, 'SECCA' category FROM dual
)what i want to do is get all rows where typecd <> PET and (typecd <> BS only when category is secc and secca)
so output should be as follow
pid      typecd    category
=====    =====     =========
2        BS        PRINC
3        CAT       PRINC
3        CAT       AC
4        PET2      SECC
4        PET2      SECCAas you can see for pid =1, the typecd is bs and category is secc and secca. so i elimate this row sinde i dont
want any rows where typecd <> bs only when category is secc and secca.
pid = 2 has typecd = pet and bs so i dont want to display the row that contain pet regardless of what category is.
however, there is a row with bs but the category is not secc or secca. so i want to display this one
pid=3 i want to diplay the two rows with typecd=cat because they either are not <> pet or <bs and belong to secc and secca.
pid=4 has pet2 and category is secc and secca but i want to display it since the typecd is not <> bs
in summary i want to get all rows with typecd <> PET regarless of category and also i want to display those rows
where (typecd <> bs only when category is secc and secca)
can someone help write a query that produce the output above? thanks you.

Try this,
SQL> WITH DATA1
  2       AS (SELECT 1 PID, 'BS' TYPECD, 'SECC' CATEGORY FROM DUAL
  3           UNION ALL
  4           SELECT 1 PID, 'BS' TYPECD, 'SECCA' CATEGORY FROM DUAL
  5           UNION ALL
  6           SELECT 2 PID, 'PET' TYPECD, 'SECC' CATEGORY FROM DUAL
  7           UNION ALL
  8           SELECT 2 PID, 'BS' TYPECD, 'PRINC' CATEGORY FROM DUAL
  9           UNION ALL
10           SELECT 3 PID, 'CAT' TYPECD, 'PRINC' CATEGORY FROM DUAL
11           UNION ALL
12           SELECT 3 PID, 'CAT' TYPECD, 'AC' CATEGORY FROM DUAL
13           UNION ALL
14           SELECT 3 PID, 'PET' TYPECD, 'AC' CATEGORY FROM DUAL
15           UNION ALL
16           SELECT 4 PID, 'PET2' TYPECD, 'SECC' CATEGORY FROM DUAL
17           UNION ALL
18           SELECT 4 PID, 'PET2' TYPECD, 'SECCA' CATEGORY FROM DUAL)
19  SELECT *
20    FROM DATA1
21   WHERE CASE
22            WHEN (TYPECD = 'BS'
23                  AND CATEGORY IN ('SECC', 'SECCA'))
24                 OR TYPECD = 'PET'
25            THEN 0 ELSE 1 END = 1;
       PID TYPE CATEG
         2 BS   PRINC
         3 CAT  PRINC
         3 CAT  AC
         4 PET2 SECC
         4 PET2 SECCA
SQL> G.

Similar Messages

  • Data filtering

    I have created a reprot using command (SQL query) which retrieves all the employee details.Now i need to filter the data based on the conditions,
    1) Employees joined in the Week numbers will be selected (example: 13,15,19) and the data should be filtered.
    2) Employees joined in the selected months. (Exacmple : 2,5 months) and the data should be filtered.
    Can anyone help me on how to filter the data? the months & weeks will be selected in the user interface.
    Edited by: sweish on May 10, 2011 7:27 AM

    Actually you'd probably want to use DatePart(wk, {TableName.DateField}) or DatePart(ww, {TableName.DateField}) as opposed to isowk.
    ww & wk will give you actual week number the date is in. isowk looks at date's day of the week and counts the number of times that day has occurred in the year
    So using today for example... Tuesday May 10, 2011
    DatePart(wk, GetDate()) = 20
    DatePart(ww, GetDate()) = 20
    DatePart(isowk, GetDate()) = 19
    The reason for the discrepancy is that there wasn't a Tuesday in the 1st week of January 2011.
    Unfortunately that's not going to get them past the whole "passing multi-valued parameters to a command" thing unless they have CR 2008...

  • Need help with data filtering on groups/application roles

    Hello,
    I have a situation where I have to apply security on objects (reports, prompts etc) and dimension members (Essbase cube). So the idea is like this:
    Report 1: access to three users (U1, U2, U3), but for dimension Company they have separate rights:
    U1: Company A, Companies A.1-A.7 (children of A) and Companies A.1.1-A.1.9 (children of A.1);
    U2: Company A.1 and Companies A.1.1-A.1.9;
         U3: Company A.1.1
    same for Report 2, but users must have access to different companyes, like Company B, B1...
    In WebLogic Console I created three groups (G1-G3) and placed each user to a group (U1-> G1, U2 ->G2, U3->G3). Then in WebLogic EM I created three application roles (R1-R3) and added for each, corresponding user (R1-> U1, R2->U2, R3-> U3).
    My approach was to use application roles like this:
    R1: include User1 and filter data on repository by application role to each generation of the cube ("Data_Source_Name"."Dimension_Name"."Generation2,Dimension"='Company A',"Data_Source_Name"."Dimension_Name"."Generation3,Dimension"='Company A.1', "Data_Source_Name"."Dimension_Name"."Generation4,Dimension"='Company A.1.1')
    R2: include User2 and filter data on repository by application role to each generation of the cube ("Data_Source_Name"."Dimension_Name"."Generation3,Dimension"='Company A.1', "Data_Source_Name"."Dimension_Name"."Generation4,Dimension"='Company A.1.1')
    R3: include User3 and filter data on repository by application role to each generation of the cube ("Data_Source_Name"."Dimension_Name"."Generation4,Dimension"='Company A.1.1').
    I've noticed that, by default, each role inherites BIConsumer and "localmachineusers" application roles, so I set in repository these both roles to filter data as the role 3 (the lowest level of acces), in order for my roles (Roles 1 to 3) to have the highest privileges.
    In repository I cannot see any of my users (U1-U3), but just the application roles they are in.
    For Report 1 I set the access to Roles 1-3 and when I am logged on as U3 this report should display only the data for Company A.1.1, but it doesn't (displays data also for Company A, Companies A.1-A.7).
    In fact it seems, that the data isn't filtered at all, which drives me to the conclusion that my data filter is override by another role, maybe ?
    Could you please give me a clue about what I am missing here ?
    Thank you.

    Amith,
    Please bear this with me - see my comments below (search for petresion_Comments):
    So, we have three users who have access to a report called Report1. But the data that they see in the report needs to be different. The report has a dimension company, and each user needs to see different companies data. So the filtering needs to be done on company dimension.
    petresion_Comment: That's my case to solve.
    Now the groups in weblogic has no purpose in OBIEE 11g unless you are using an LDAP authenticator who has groups defined in the active directory. By this I mean the network people are maintaining the users and group relation necessary for OBIEE. So keeping the weblogic groups apart for a minute, lets deal with users and roles only.
    The three users are assigned to three different roles R1, R2 and R3. By default, all the roles inherit the BIconsumer role, and localmachineusers role you mentioned is not an OTB role. This is something that is probably causing the data filtering to fail. Do a test like create a user in weblogic, assign him only to the localmachineusers role, and go to analytics, and check your roles and groups by going under my account. Make sure this role is not inheriting any other roles like BIAdministrator, BIauthor etc. So in conclusion, when one of your users login, they should inherit only their custom Role (R1 for instance), BIConsumer, Authenticated User, and your custom role localmachineusers.
    petresion_Comment: That is what I checked on the first time (few days ago) and is exactly as you say (BIConsumer, localmachinerole and Role1).
    Do not apply any data filters on the BIConsumer role. This is not a good practice because the filters get applied to every single user that logs into the system.
    petresion_Comment: I know that, but appliyng filters on BIConsumer role I tried to make sure that its privileges doesn't overrides any of my Roles (1,2 or 3). I will remove the filter on BIConsumer.
    Now create the data filters on your custom roles (R1, R2, R3). Save the RPD. Deploy the Rpd through Enterprise Manager.
    petresion_Comment: Only difference in my case is that I stopped BI services, applied changes to rpd in Offline mode and then restarted BI services.But also tried as you mentioned (by the book in fact) and same result. The problem is the same, my roles(1,2,3) don't filter the companies at all.
    Once you are done with all the work above, you should login into analytics as user1. After logging in go to my account, roles and groups, and make sure you see the R1 in the list of groups. Now run the report, and your filters should get applied no matter what. If they are still not getting applied, grab the physical sql and see if the filters are existing in the where condition.
    petresion_Comment: Where can I capture the physical SQL (probably an MDX sent to the Essbase cube ?) ?
    One other reason could be, one of the roles that are assigned to the user1 by default, is overriding the filters. Like for example, if a user is assigned to BIAdmin role, and no matter if you assign him to a different role that has 100's of filters, he will still see all of the data.
    petresion_Comment: As I said before, each of my users are members of their roles, BIComsumer and localmachinerole, so no other privileges (no BIAdmin role).
    Thank you for the patience.
    John

  • How can i extract the particular data from Base tables

    Hi
    I have some Base R/3- Tables . I need to exact the data from these base tables.
    But i need to select some type of datarecords(eg: select Material Documents from MSEG and MKPF tables based on movement types 261,262).
    Something like that . So how can i select the particular category datarecords from base tables. Anyway im going to create the Custom DataSource.
    So please let me know . how can i extarct tha particular data from base tables
    kumar

    Hi Venkat
    See i have some 5-tables . I need to extarct from these tables.
    first i need to extract the data from one table fully.
    Then i need to extarct the data from second table based on profict centers, company codes of first table.
    Then i need to extract the data from third table based on profict centers of first table and movement type = 2p,2n,2s condition.
    So how can i extarct like this data from multiple tables.
    Please let me know
    kumar

  • Selecting data on basis of string from ms access using database toolkit

    i want to read data from ms access in labview using database toolkit,but the problem is that i want to enter/select pipetype and other fields must be filled from the database with respect to pipe type intead of indexing(1,2,3,....)..kindly tell me how to make my selectio from database depending on pipe type.
    Attachments:
    database.zip ‏324 KB

    What is pipetype and what exactly do you mean by 'selecting data on basis of string'.

  • Output determination with base pricing condition types

    Hi folks,
    got a question regarding the Output determination..
    In the outptut type i.e order confirmation and change order confirmation, it is showing the the base price condition type i.e PR00.
    But the client wants it to pick up the condition type material discount k004...
    is it possible ?   because what my understanding was that the output types typically picks the base condition type PR00.
    but the client wants it to pick up this K004..
    can anyone say how to do this....
    thanx in advance,
    sourav
    I

    In the Pricing procedure configuration there is a column Print, where for each condition you may specify if and how the condition should be printed. There is good documentation (F1) available on this field. Clear this field on PR00 and set to 'a' (or any other applicable value) for K004. This change will affect all the documents that are using the same pricing procedure though.
    Otherwise either the output processing program or the form (both names may be found in the Output configuration) will have to be changed or, if the standard ones are being used, those will have to be copied as the custom (Z...) objects and then modified accordingly.

  • View Customization Table changes and Data  table base changes in a report

    Hi All,
    How to view Customization Table changes and DAta  table base changes in a report ,
    Is it right transactions: SCU3 or RSVTPROT
    Also plz let me know the concept of audit trial,
    Thanks
    SD

    Hi,
    Changes to master data objects must be captured for the For compliance purposes. The auditor allows you to be able to view and print an audit log of changes to master data objects for a chosen period. It is very common for external auditors to focus on what has changed from one year or quarter to the next to help determine the nature, extent, and population for testing. To configure and access your audit log, perform the actions listed with each of the following utilities.
    Audit Trail is used to track the record changes.
    The report RPUAUD00 gives all the changes done to the masterdata by any user anytime.
    But, before using this audit trial, please ensure that the system hardware is well equipped as the audit trials activation would later become a performance issue as this would occupy a lot of space in the coming time.
    Best Regards,
    Venkat.

  • What is Data filtering and Segment filtering in ALE/IDOCs

    Hi sap gurus
    what is Data filtering and Segment filtering in ALE/IDOCs

    Hi,
    Filtering at the IDoc Level
    Identify the filter object (BD59)
    Modify the distribution model
    Segment Filtering
    specify the segments to be filtered (BD56)
    The Reduced IDoc Type
    Analyze the data.
    Reduce the IDoc type (BD53)
    Thanks and regards.

  • Load data filtering on a dimension's member - ESSCMD MaxL

    Hi.
    I would like to load data filtering records on a dimension's member. Referring as example to Sample's database outline, I would like to load only records with product 100-10.
    I know that I can use Select command from Record 's rule menu in Administration Console; however, I would like to use ESSCMD or Maxl to do the same.
    Is it possible? Any issue?
    Thanks a lot in advance.

    No it's not possible. The selection/rejection criteria are in the load rules and you can't pass parameters to them.
    I think in 9.3.1 you could put a substitution variable in a load rule but have not tried it yet. If so, you could add that to MaxL to update the variable then use the load rule to load the data. You will have to try it as I have not done so yet.

  • Scale basis in condition type?

    Hi
    I want to know the exact functionality of Scale basis in a condition type.
    Basically what does scale basis, scale formulae, check value ,scale type etc mean?
    Explanation with an example would be highly appreciated.
    Also we do maintain scale basis at condition record level, then whats the difference between the two?
    Thanks

    Hi ! Christino,
    Q) functionality of Scale basis in a condition type?
    A) The entry made here decides whether the condition value calculated is on the base of per quantity(say per pc or per no.) or per weight(say per Kg or per pound) or per volume(say per litre or per ml or per cm^3)
    Q) What does scale formulae, check value ,scale type etc mean?
    A) Scale Formulae - is a setting(ABAP/4 code you write) to make condition value to be calculated any other than those mentioned in the above answer.
    ->Check value field once set helps in deciding whether the scales you mentions have to be in a ascending or descending in scales rate
    (ex.for Material A 1pc to 50pc price is $100
                             51pc to 200pc price is $99
                            201pc to 500pc price is $98, is an example of ascending scale rate. descending is opposite)
    -> Scale type is setting the validity of the scale (say the scale rate starts from a particular point of quantity or value)
    Q)Also we do maintain scale basis at condition record level, then whats the difference between the two?
    A) at the condition record level it just a reflection of what scale basis you have set in customizing of Condition type.
    Hope this helps. Do provide your feedback.
    Regards,
    PATHIK
    Message was edited by:
            Pathik Pandya

  • Is Data filtering possible in TreeTable examlple 0.

    Hello everyone,
    I have used an opensource example "TreeTable example 0" provided by sun to develop an application and it is working very file for me. But Now, I want to develop a feature of data filtering whether column wise or data wise.
    So, is it possible to achieve it in that code.

    Hello,
    See these docs,
    [System Copy Procedures |https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/50960d8f-6542-2a10-3ba8-e46dc23dd9b1]
    [System Copy and Migration|System Copy and Migration ]
    [Setting up Business Intelligence Client in NW2004s|https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/007af9a7-e48e-2a10-5c85-fcac22d58e82]
    [System Copy for SAP Systems Based on SAP NetWeaver 2004s SR2 ABAP and Java|https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/200ebc93-dabe-2910-c1a6-c4ec30b20e04]
    [Homogeneous and Heterogeneous System Copy for SAP Systems Based on SAP NetWeaver 2004s|https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/f022aa7d-0c01-0010-20a5-c247330d47fa]
    [System Copy for SAP Systems Based on SAP NetWeaver 2004s SR1 ABAP|https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/d10bf27d-0c01-0010-6995-bbdcdf0118a1]
    [System Copy for SAP Systems Based on SAP NetWeaver 2004s SR2 ABAP|https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/e08502d4-dabe-2910-bbb4-c1bfc82aed73]
    [System Copy for SAP Systems Based on SAP NetWeaver 2004s SR2 Java|https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/20bd5cee-dabe-2910-fb97-c082a7c9c682]
    Thanks
    Chandran

  • Error when applying data filters on Logical Dimensional Table

    I have a data filter setup on a dimension table using session variables. The session variables are getting populated in the correct way. To make sure, I created an analysis with session variables, and I see the values that I need to apply the data filters.
    When I select a column from the dimensional table in the presentation services, I am getting below error.
    Error getting drill information: SELECT "GL Segment3 - Office"."Region Code" saw_0 FROM "Financials - AP Overview"
    Error Details:
    Error Codes: YQCO4T56:OPR4ONWY:U9IM8TAC:OI2DL65P
    Odbc driver returned an error (SQLExecDirectW).
    State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 43113] Message returned from OBIS. [23014] The Variable with Object ID '3031:338998' is still referenced and could not be loaded.Please have your System Administrator look at the log for more details on this error. (HY000)
    SQL Issued: {call NQSGetLevelDrillability('SELECT "GL Segment3 - Office"."Region Code" saw_0 FROM "Financials - AP Overview"')}
    Thanks,
    -Amith.
    Edited by: Amith on May 3, 2011 12:19 PM

    You can go into the BI Administration tool, then go to tools. After that go to Query Repository.
    In the "name" field leave the "*". Set the "type" to variable and do not establish a filter.
    Once you hit query you should see all of the repository variables listed and you can see the code that is throwing you the error. Although, in my case it is throwing me a code that does not exist in this list. I'm a bit stuck as well.
    Anyone?

  • Show and hide Lov icons and Date Picker image on conditional?

    How to show and hide Lov icons and Date Picker image on conditional?

    Why do you just want to make the icons conditional? Shouldn't the field also be conditional?
    Patrick
    My APEX Blog: http://inside-apex.blogspot.com
    The ApexLib Framework: http://apexlib.sourceforge.net
    The APEX Builder Plugin: http://sourceforge.net/projects/apexplugin/

  • Data filtering not activated for ALE processing of Outbound Deliveries

    Dear all,
    we're currently upgrading from 4.6c to ERP 6.0 and are facing a serious problem with our IDoc interfaces:
    In 4.6c, data filtering for Message Type SHP_OBDLV_SAVE_REPLICA was activated and use to extract some segments from the IDoc sent to our logistics provider.
    In ERP 6.0 data filtering is not activated for SHP_OBDLV_SAVE_REPLICA and we do not know how to activate it. For some reason, we can still see the data filtering setting when we switch to "system view" in BD64 but we're not able to change it.
    Checking filter settings in the old system using transactions BD60, ... we do not see any clue how data filtering or filter objects have been defined for SHP_OBDLV_SAVE_REPLICA.or in it's context
    Help please - thank you very much in advance,
    Martin Pluntke

    Dear all,
    thank you for your help. I've just realized that the former project team made a modification to object LIKP, method SAVEREPLICA in transaction BDBG and set it to "Data filtering allowed".
    This setting was lost during upgrade.
    Last question: When redoing this modification (I hate to do this but that's the only way to keep the interface running) and save it I get an error/warning message during generation that the definition is inconsistent. I can continue the generation or cancel it. However, the switch is activated and my filter settings suddenly appear again in BD64 (they've been there all the time, but not displayed or active).
    Is there anything I've to keep in mind? Can I generate, should I ignore?
    Thank you all for your help,
    Martin
    Edited by: Martin Pluntke on Feb 8, 2008 4:37 PM

  • Decoded datas to Base 64

    i try to convert to decode data to base 64 using bouncy castle lib.
    after decoding i got Bizarre characters
    my input data :IzIrnQA2aQbOw5ysPJJumDSspCvdwd/zec21/K+t1RlXsjid6vpNsNKVgCH5KfMIeqXFsGEKRZO/4Xd2nZYND32eSdbbqgkDFMsYK8qSFQo2gvYwHXAQg5BEvB51zldef4mr06GXldtTIZSKfGMI1WcoM92Zi9P1sfZd2hfy7zc=
    out data :
    #2+?&#65533;6i????<?n?4??+????y??????W?8???M????!?)?z???a
    E???wv??
    }?I???     ?+??
    6??0p??D?u?W^???????S!??|c?g(3???????]???7
    is it correct? thank you for any response

    bada wrote:
    Hear is the line of my code.
    import org.bouncycastle.util.encoders.Base64
    String decodedStr ="IzIrnQA2aQbOw5ysPJJumDSspCvdwd/zec21/K+t1RlXsjid6vpNsNKVgCH5KfMIeqXFsGEKRZO/4Xd2nZYND32eSdbbqgkDFMsYK8qSFQo2gvYwHXAQg5BEvB51zldef4mr06GXldtTIZSKfGMI1WcoM92Zi9P1sfZd2hfy7zc=";
    byte[] signBytes = Base64.decode(decodedStr.getBytes("UTF-8"))
    System.out.println(new String(signBytes ));
    Do you see something wrong in the code.Yes. Don't convert the signBytes to a String since (reading between the lines) it is a signature which is binary data and not characters.

Maybe you are looking for