Query to Identify Sets Having Given Pattern

Hi,
Assume that i have following table
Id Code
1 aaa
1 bbb
1 ccc
2 aaa
2 bbb
2 ddd
3 bbb
3 eee
The records will be grouped by Id. I want to identify sets having following criteria
1. Set should have at least one record with code like 'a%'
and should have at least one record for codes 'bbb', 'ccc' (in this case group 1 would be selected)
2. Set should have at least one record with code like 'a%'
and should have at least one record for either 'bbb' or 'ccc' (in this case group 1and 2 would be selected)
Does anyone have idea about how this could be achieved efficiently? Any pointers, references would be appreciated
Regards
~Pravin.

Problem 1 Can be solved like:
SQL> select * from t;
        ID CODE
         1 aaa
         1 bbb
         1 ccc
         2 aaa
         2 bbb
         2 ddd
         3 bbb
         3 eee
8 rows selected.
SQL> select id
  2  from t
  3  group by id
  4  having sum(case when code like 'a%' then 1 else 0 end) > 0
  5  and sum(decode(code,'bbb',1,0)) > 0
  6  and sum(decode(code,'ccc',1,0)) > 0;
        ID
         1
<br>
<br>
Similarly Problem 2 can also be solved...                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

Similar Messages

  • How to convert an array having ramp pattern to ..................

    i used an ramp generator to obtain numbers. the output is an array
    having ramp pattern. how do i convert it to a set of numbers?
    thank you,
    siva.

    Hi Siva,
    Take a look at the example that can be found at
    Help >>> Search Examples >>> Browse >>>Hardware Input and Output >>> DAQ >>> Analog Output >>> Continuous Generation.VI.
    You are not going to be able to get better than 1KHz out of your digital output line becuase Windows was never designed to be able to let you cycle that fast. It was designed to to 30Hz, just fast enough to make it look like it is smooth.
    The example I cited should let you "crank-up" your output speed. You will probably have to modify it to get a square wave but, that is just data.
    Trying to help,
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • Suddenly cannot set a Desktop Pattern on PBG4 - 10.5.8

    After over 6 years with my PowerBook G4 (which today serves as a great backup Mac that has saved me twice when my MBP-13" (mid-2010) motherboard has gone down and needed replacement!)--- SUDDENLY I cannot set a Desktop Pattern - it is just white.
    The patterns / images are there and they show in the System Preferences "Desktop/ScreenSaver" -- and the images in the respective folders are valid ones…
    I repaired the HD - it took hours but this morning reported OK - and I will repair permissions (this seems to be running for a long time now…)
    Everything else seems to work fine-- and up until a few days ago I could set the "wallpaper" or "Desktop Pattern" of my choice.
    A few days ago I did connect my PBG4 to a TV for watching QuickTime movies via an adapter - and used screen mirroring and QT7 pro which all worked great - it seems it might be at that time that I started having the problem setting the Desktop Pattern (i.e. when I could no longer set it!)
    Thanks for any comments. 
    Wednesday 2 November 2011

    More information on this mystery:
    1.  With an external TV via red-yellow-white cables with external TV adapter -- when set for NOT-mirrored, I can set a desktop pattern on the TV, but not see one on the PBG4.
    2.  When I hit F9 - the white desktop pattern moves away, revealing the desktop pattern I have set, but somewhat hazy - i.e. not fully clear.
    3.  When I do a restart --- after everything else is gone, for a few seconds the desktop pattern I set (and this can be any) shows---
    Very perplexing--   Again, I did a full REPAIR DISK and REPAIR PERMISSIONS - that has not helped.
    Wednesday 2 November 2011 later in the morning

  • Sql query to identify all the responsibilities attached to a form

    (oracle - apps) Can anyone help me by giving a sql query to identify all the responsibilities attached to a form and corresponding menu should not be in the menu exclusion.
    Thanks in advance
    Venki

    Bump

  • Disadvantage of 'QUERY ALL RECORDS' set to YES in DATA BLOCK

    Dear all,
    Can any one tell me disadvantage of 'QUERY ALL RECORDS' set to YES in DATA BLOCK. I have made a datablock 'QUERY ALL RECORDS' set to YES becoz of requirement 'restrict duplicate data entry'.For your information
    my datablock is multi record.
    Than You

    What if you have 1,000,000 records in your table and you query all records. Ouch!
    restrict duplicate data entryThat is standard database functionality: primary or unique key on the table.

  • Query to Identify Compressed Tables?

    Is there a query to identify which tables are compressed? 
    Isn't the following query limited to just the partitioned tables that are compressed? 
          SELECT DISTINCT NAME
          FROM   sysobjects x
          WHERE  x.id IN (SELECT OBJECT_ID
                          FROM   sys.partitions
                          WHERE  data_compression <> 0)

    Hi,
    Does this query helps
    SELECT
    SCHEMA_NAME(sys.objects.schema_id) AS [SchemaName]
    ,OBJECT_NAME(sys.objects.object_id) AS [ObjectName]
    ,[rows]
    ,[data_compression_desc]
    ,[index_id] as [IndexID_on_Table]
    FROM sys.partitions
    INNER JOIN sys.objects
    ON sys.partitions.object_id = sys.objects.object_id
    WHERE data_compression > 0
    AND SCHEMA_NAME(sys.objects.schema_id) <> 'SYS'
    ORDER BY SchemaName, ObjectName
    Taken from
    Here
    Please mark this reply as answer if it solved your issue or vote as helpful if it helped so that other forum members can benefit from it.
    My TechNet Wiki Articles

  • Please advise what is the query to identify a SQL executed time

    Hi all
    Please advise what is the query to identify a SQL executed time.
    eg, a DML executed at 16-Apr-2013 11:45hrs

    Try like..
    select LAST_LOAD_TIME, ELAPSED_TIME, MODULE, SQL_TEXT elasped from v$sql order by LAST_LOAD_TIME desc

  • Query to identify the recovery catalog database name from target database

    Hi,
    How to get the recovery catalog database name from the registered target database?
    i dont know my recovery catalog database for my target database.
    I know we can use the query
    select * from rc_database;
    from recovery catalog database to know all the registered database with the recovery catalog but I want to know is there any way or query to identify the recovery catalog database name from target database to which the target database is registered
    With Regards
    Boobathi P

    You can check the backup scripts which you use to backup your target database to get the catalog database name.
    And check the corresponding connect string in TNSNAMES.ORA file or tnsping to get the server details of the catalog database.
    Edited by: gopal on Apr 12, 2013 12:59 PM

  • Control temperature according to given pattern

    Hello,
    I want to control temperature of a chamber using heater and fan. I have a given pattern according to which I have to vary the temperature.
    Attached are files for reading the temperature and files for heater and fan control.
    Now, my job is to develop an algorithm to vary the input temperature according to the desired temperature shown in the attached graph. How do I do this? Please help!
    Attachments:
    Lab3_Part2_SubVIs.zip ‏32 KB
    pattern to follow.docx ‏57 KB
    HeaterFanControl.zip ‏13 KB

    With a folder called Lab3_Part2... this looks like a school assignment.  So we will not do your homework for you.  If you have specific questions about things, people on the Forum will be glad to help.
    Some suggestions: Creating a task, reading data, and closing the task in a subVI which gets called repeatedly is usually not a good idea.  Put the Task creation outside the loop.  Read the data inside the loop as soften as needed. Close the task after the loop completes.
    Avoid the use of sequence structures. Use dataflow.  Search on the Forum for Sequence Structures to learn why.
    Limit the use of Formula nodes to places where LV primitives do not work well.  You do not have any such places.  For example in the ChamberTempControl.vi just use constants with the values 1 and 2 in place of the Formula nodes.  You do not need the case structure either.  Use the Select function from the Comparison palette.
    How do you plan to get the pattern into your program? You do not show anything for that.
    Lynn

  • Script to find Jobs in a Request Set having incompatibilities

    All,
    Could anyone please share - Script to find Jobs in a Request Set having incompatibilities.
    Working on R12.1.1
    DB:11.1.0.7
    Thanks for your time and help!
    Regards,

    Could anyone please share - Script to find Jobs in a Request Set having incompatibilities.Please see this thread -- Re: incompatibilities table
    Thanks,
    Hussein

  • O365 Calendar query - cannot identify recurring events

    I am having trouble finding a way to efficiently handle recurring events through the O365 API. There
    does not seem to be a straightforward way to identify if an event recurs.
    I am using the O365 API to display calendar events within a specified day on my web app. The user
    picks a day, and my app displays the events for that day mirroring what is shown in OWA. I am querying the calendar events endpoint (../Me/Calendar/Events) and filtering the results using $filter in the query to narrow the response down to events for that
    day.
    However, this approach does not catch recurring events since the query only returns original event
    objects, not their recurrences.
    To solve that problem, I was hoping to query that same endpoint and filter off of the "Recurrence"
    property. I found that this property is always null. However, if I query a specific event using its ID (../Me/Calendar/Events(<event id>)), the response includes everything I need to reconstruct the recurrence pattern (i.e. frequency, day of week, #
    of occurrences, etc.).
    Although this gives me a way to handle recurring events, it is very inefficient to loop through each
    event to check for recurrences. This option is impractical since I would have to check all events ever created.
    Has anyone else come across this and is there a good way of handling recurring events through the
    O365 API?

    I found another property called "Type" which is of model
    Microsoft.Exchange.Services.OData.Model.EventType. The value "SeriesMaster" indicates that the event recurs, while "SingleInstance" is a one-time event. I tried using O365's $filter to filter the query as shown below
    ...<api_endpoint>?$filter=Type eq Microsoft.Exchange.Services.OData.Model.EventType'SeriesMaster'
    This query returns no values back.
    My other option, which is to get all events and filter on this property, will work and is much better than the previous option I posted above, but impractical for a user with many events.
    Is there a way to filter on this property via http query?

  • SQL Query to identify duplicates

    Hi All,
    I want to identify and display some duplicate data from the database.
    With duplicates I mean rows in a table that contain identical information in a combination of fields (Last Name, First Name, City).
    Example:
    ID1     ID2     Last Name First Name  City               Phone
    1005  2010    Krieger      Jeff             San Ramon     9252997100
    1012  2010    Krieger      Jeff             San Ramon     9252997100
    1017  2010    Krieger      Jeff             San Ramon     9252997100
    Now I want to select the IDs (ID1 and ID2) that identify each duplicate rows.
    Therefore I want to create a query with a subquery inside, similar to this:
    SELECT ID1 ID2 LastName FirstName
       FROM Customers
       INTO TABLE
       WHERE (LastName FirstName City) IN
       (SELECT LastName FirstName City
           FROM Customers
           GROUP BY LastName FirstName City
           HAVING COUNT(*) > 1)
       ORDER BY LastName FirstName.
    How would be the syntax in ABAP, because I am not able to define more than one field after WHERE?
    Any Ideas how to identify the duplicate data and return the ids?
    Thanks for any help!

    Is this something you need to do via code or can you use an analysis tool?  TAANA & TAANA_AV allow you to analyze distribution spreads by table fields (you can pick your table and the fields).  It's primarily used for archiving analysis but it's helpfuul in other scenarios as well.  It's not optimal for finding single record dupes but I thought I'd throw it out there.

  • Help with doing SELECT sub query within the SET of an UPDATE statement

    After doing some research, it appears as if it's possible to use a SELECT subquery in the SET of an UPDATE statement.  i did find some examples and here is my code, however when I click the "check" button it's saying the field (my entire select subquery) is unknown and neither in one of the specified tables or defined by a "DATA".  Do I have a syntax issue or is there another reason why it's not taking this as a valid statement?  Thanks for the help!
    LOOP AT IT_DATA
    UPDATE /BIC/AZDP_O0140
       SET /BIC/ZCOUNTER = (SELECT COUNT( DISTINCT MATERIAL )
                            FROM /BIC/AZDP_O0140
                            WHERE MATERIAL EQ IT_DATA-MATERIAL
                            GROUP BY MATERIAL).
    ENDLOOP.

    my Update does indeed have a WHERE clause but because of the issue i'm having, all my criteria in my WHERE is black text in the ABAP editor.  The editor doesn't even recognize the keywords "WHERE" or "EQ".  Below is my entire statement which contains all WHERE criteria in both the Update and the Subquery, i've just removed it for testing to help simplify the query and eliminate as many other factors as posisble that may be causing problems:
    LOOP AT IT_DATA.
       UPDATE /BIC/AZDP_O0140
       SET /BIC/ZCOUNTER = (SELECT COUNT( DISTINCT MATERIAL ) FROM /BIC/AZDP_O0140
       WHERE WHSE_NUM EQ IT_DATA-WAREHOUSE
        AND  PLANT EQ IT_DATA-PLANT
        AND  /BIC/ZTRAN_NO EQ IT_DATA-TRANS_NUM
        AND  DELIV_NUMB EQ IT_DATA-DELIVERY
        AND  MATERIAL EQ IT_DATA-MATERIAL
        GROUP BY MATERIAL)
       WHERE WHSE_NUM EQ IT_DATA-WAREHOUSE
        AND  PLANT EQ IT_DATA-PLANT
        AND  /BIC/ZTRAN_NO EQ IT_DATA-TRANS_NUM
        AND  DELIV_NUMB EQ IT_DATA-DELIVERY
        AND  MATERIAL EQ IT_DATA-MATERIAL.
    ENDLOOP.
    i should also mention the sources i found were not within the SAP Library but instead on other third-party ABAP websites.  so because i was having issues i wanted to post here to see if anyone else has come up with a working solution.  but if this cannot be done i can likely come up with a solution for my needs using multiple internal tables, this would just have been much easier since i can get a query like this to do what i want in SQL Server.  Thought i could utilize this in ABAP as well.

  • Query to identify Workbooks dependent on Discoverer/Database Function

    Hi,
    We are having a Discoverer/Database function that is being used in several Discoverer Reports.
    We now have to add a parameter to that function and we are not sure on what all reports are actually using this function.
    Can you please provide me the query (or) an approach to identify all the discoverer workbooks that are dependent on this function?
    Appreciate your help.
    Thanks,
    Kesava

    Hi Tracy,
    there is no connection between those workbooks, the adjusted reports are saved as new reports and
    there is no pointer to the original report it was created from.
    Tamir

  • Another JS query please - identifying paragraphs by length

    Hi all
    Based on all the new things I discovered yesterday I want to build upon on one of the code snippets and use it to identify all paragraphs up to 10 words in length and apply a "heading" paragraph style. I'm starting with
    app.findGrepPreferences.findWhat = "^.+$";
    myResult = app.activeDocument.findGrep ();
    so myResult contains all paragraphs in the story and next I want to say something like
    myHeadings = those paras whose myResult.length is between 1 and 10
    but I don't know how. After that I think I know how to apply a style to the myHeadings paragraphs (myHeadings.appliedParagraphStyle="A head";).
    Is this a job for a for loop to go through the contents of myResult? But if so what am I looping and how do I get the result of that into myHeadings?
    thanks,
    Iain

    > app.findGrepPreferences.findWhat = "^.+$";
    > myResult = app.activeDocument.findGrep ();
    > so myResult contains all paragraphs in the story
    This is not a very efficient approach. Also, it will get you all paragraphsi in the Document, not the story.
    Additionaly, if you don't set the preferences, it will remember the preferences from whatever has run before, which could do almost anything...so you should always initialize them first:
    app.findGrepPreferences = NothingEnum.nothing;
    app.changeGrepPreferences = NothingEnum.nothing;
    Anyhow, the efficient way to get all the paragraphs is to use:
    myResult = app.activeDocument.stories.everyItem().
                   paragraphs.everyItem().getElements();
    though that uses the .everyItem() syntax which is confusing to understand...
    > myHeadings = those paras whose myResult.length is between 1 and 10
    > but  I don't know how.
    > Is  this a job for a for loop to go through the contents of myResult? But  if so what am I looping and how do I get the result of that into  myHeadings?
    Yes, you're on the right track. Simply declare a looping variable, check the length of myResult.words.length, and loop over everything from 0 to myResult (minus 1, since you're starting to count at zero; if there are 2 items in myResult, myResult.length is 2 but myResult[0] and myResult[1] will be valid and myResult[2] will not).
    Note that myResult.length is the length of myResult -- the number of results -- the number of paragraphs in the document. That's not what you want to check. If you want to check the number of words (as opposed to the number of characters or something else), you need to look at myResult[someNumber].words.length. Here I stick it in a variable, to avoid having to write it out twice:
    var i, wordCount;
    for (i=0; i<myResult.length; i++) {
      wordCount = myResult[i].words.length;
      if ((wordCount >= 1) && (wordCount <= 10)) {
        myResult[i].appliedParagraphStyle = "A head";

Maybe you are looking for

  • Dynamic forms in struts

    Hi, I have a pretty difficult problem that I don't know how to solve using struts. I need to generate dynamic surveys from a database. The structure of the survey can be different for every different user. I really want to use the struts Form classes

  • How to send results to actionscript using java via HttpService

    Hi, I do RPC using HttpService. In my situation, I need to send results from Java code to Flex Action script. I have defined a Java Servlet receiving data from Flex application, then it processes with the data, finally the Servlet is supposed to send

  • Configuring more than one LDAP as data source

    Hi Portal Gurus, We have requiremnt to configure  MS ADS LDAP-> DEEP HIERARCHY  & Sun one LDAP->FLAT HIERRARCHY as PORTAL Datra Source.we have already configured MS ADS LDAP. for  merging these 2 LDAPS as a data source can anybody having experiece ..

  • Help on browser plugins

    Hi everybody! I need your help on this. I am creating a browser plugin. So here it goes: Do you think Flex will be effective on this side? Say for instance, i'll create a browser plugin that allows users to insert images to email. these images are be

  • Dual Layer DVDs       +R vs. -R

    Which one should I buy? which one is compatible with all players or most? +R? Is there a way of compressing the video so that I can decrease the GB? Would love to use single layer if i could. my vid is about 90mins. thanks! Scott