Using the query with filtering the records

I have a requirement with table and all of the following data
create table test_sty 
( a_id number, s_txt varchar2(33), rank_cd varchar2(33), rank_sym_cd varchar2(33),
c_cd varchar2(33), d_date date, o_cd varchar2(33), a_rank_id number, i_id number, i_det_id number,
c_txt varchar2(33), d_txt varchar2(33), a_name varchar2(33), a_typ_id number, m_id number, r_cat_cd varchar2(33),
r_sec_cd varchar2(33), r_sub_cd varchar2(33), c_link number
)

insert into test_sty ( a_id, s_txt, rank_cd, rank_sym_cd, c_cd, d_date, o_cd, a_rank_id, i_id,
i_det_id, c_txt, d_txt, a_name, a_typ_id, m_id, r_cat_cd, r_sec_cd, r_sub_cd,
c_link ) values ( 
200, ' Y_UTY', 'SH', 'B+', null,  sysdate
, 'NA', 497, 978, 5098, '74C1', 'CP', 'U_L', 1, 101, 'P_H', 'GO', 'NA', 12); 
insert into test_sty ( a_id, s_txt, rank_cd, rank_sym_cd, c_cd, d_date, o_cd, a_rank_id, i_id,
i_det_id, c_txt, d_txt, a_name, a_typ_id, m_id, r_cat_cd, r_sec_cd, r_sub_cd,
c_link ) values ( 
200, ' Y_UTY  ', 'SH', 'B+', null,  sysdate
, 'NA', 497, 978, 5098, '74C1', 'CP', 'U_L', 1, 101, 'P_H', 'GO', 'NA', 12); 
insert into test_sty ( a_id, s_txt, rank_cd, rank_sym_cd, c_cd, d_date, o_cd, a_rank_id, i_id,
i_det_id, c_txt, d_txt, a_name, a_typ_id, m_id, r_cat_cd, r_sec_cd, r_sub_cd,
c_link ) values ( 
100, ' Y_CUTY  ', 'SL', 'BC', null,  sysdate
, 'STL', 427, 529, 9409, '245', null, 'U_L', 1, 101, 'P_H', 'GO', 'NA', 24); 
insert into test_sty ( a_id, s_txt, rank_cd, rank_sym_cd, c_cd, d_date, o_cd, a_rank_id, i_id,
i_det_id, c_txt, d_txt, a_name, a_typ_id, m_id, r_cat_cd, r_sec_cd, r_sub_cd,
c_link ) values ( 
100, ' Y_CUTY  ', 'SL', 'BC', null,  sysdate
, 'STL', 427, 565, 1567, '285', null, 'U_L', 1, 101, 'P_H', 'GO', 'NA', 24); 
insert into test_sty ( a_id, s_txt, rank_cd, rank_sym_cd, c_cd, d_date, o_cd, a_rank_id, i_id,
i_det_id, c_txt, d_txt, a_name, a_typ_id, m_id, r_cat_cd, r_sec_cd, r_sub_cd,
c_link ) values ( 
300, ' Y_CUTY  ', 'SL', 'BC', null,  sysdate
, 'STL', 427, 728, 1864, 'B34', null, 'U_L', 1, 101, 'P_H', 'GO', 'NA', 24); 
insert into test_sty ( a_id, s_txt, rank_cd, rank_sym_cd, c_cd, d_date, o_cd, a_rank_id, i_id,
i_det_id, c_txt, d_txt, a_name, a_typ_id, m_id, r_cat_cd, r_sec_cd, r_sub_cd,
c_link ) values ( 
300, ' Y_CUTY  ', 'SH', 'BC', null,  sysdate
, 'STL', 427, 873, 1218, '74U', null, 'U_L', 1, 101, 'P_H', 'GO', 'NA', 24); 
The requirement is to a_id may rank_cd = (SL and SH) OR (SL only)
but he shouldn't have rank_cd= HS only

A_ID = 200 RANK_CD = "SH" and this allowance A_ID = 200, it has a record with RANK_CD = SL
If such records should be removed from the selection list

For A_ID = 100 RANK_CD = 'SL' (even if it's not have SH, it can be allowed)
For A_ID = 300 RANK_CD = 'SL' AND SH, so it can be allowed
Expected Output 
a_id in( 100,300)
After the abvoe filtering condition, I need display all the columns in the table.

Could you help me with this

Published by: Smile on July 20, 2012 06:14
/* Formatted on 7/20/2012 5:17:37 PM (QP5 v5.139.911.3011) */
SELECT *
  FROM tesT_sty
 WHERE A_ID IN (SELECT DISTINCT (A_ID)
                  FROM tesT_sty
                 WHERE RANK_CD = 'SL');

Tags: Database

Similar Questions

  • How to use the record type as a parameter IN PL/SQL procedure or package

    Hi people,

    I need help on the record as the OUT parameter type. I am able to get out a single line as a parameter, but not getting do not idea how to get a multi ranks as output parameter.

    I have the code that works very well for a single line. Please see CODE1.

    But when I try to get several lines, I'm failing to do. Please see the CODE2. I get the error of compilation as


    Error report:

    ORA-06550: line 11, column 35:

    PLS-00487: Invalid reference to the variable "P_NAME.

    ORA-06550: line 11, column 1:

    PL/SQL: Statement ignored

    06550 00000 - "line %s, column % s:\n%s".

    * Cause: Usually a PL/SQL compilation error.

    Any help or a sample execution of script would be really useful.

    Thanks in advance.

    YZ

    --------------------------CODE1------------------------------------------

    -------------------------Package Spec-------------------------------

    CREATE OR REPLACE

    PACKAGE xx_sample_pkg as

    --

    Xx_sample_table_rectype RECORD TYPE IS

    (p_name varchar2 (40))

    number of p_emp_id

    );

    PROCEDURE xx_sample_prc (xx_sample_rec1, OUT xx_sample_table_rectype);

    END xx_sample_pkg;

    ------------------------------Package Body------------------------

    create or replace

    PACKAGE xx_sample_pkg AS BODY

    --

    PROCEDURE xx_sample_prc (xx_sample_rec1 OUT xx_sample_table_rectype) IS

    BEGIN

    SELECT ename, empno

    IN xx_sample_rec1

    FROM scott.emp

    WHERE ename = 'SMITH ';.

    END xx_sample_prc;

    END xx_sample_pkg;

    -------------------------------------------Execute----------------------

    DECLARE

    l_rec_type xx_sample_pkg.xx_sample_table_rectype;

    BEGIN

    dbms_output.put_line ('xx_sample_prc appeal');

    xx_sample_pkg.xx_sample_prc (l_rec_type);

    dbms_output.put_line ('YZ' | l_rec_type.p_name |') '|| l_rec_type.p_emp_id);

    END;

    ---------------------------------------------------------------

    -------------------------CODE2-------------------------------------------

    -------------------------Package Spec-------------------------------

    CREATE OR REPLACE

    PACKAGE xx_sample_pkg as

    --

    Xx_sample_table_rectype RECORD TYPE IS

    (p_name varchar2 (40))

    number of p_emp_id

    );

    PROCEDURE xx_sample_prc (xx_sample_rec1, OUT xx_sample_table_rectype);

    END xx_sample_pkg;

    ------------------------------Package Body------------------------

    create or replace

    PACKAGE xx_sample_pkg AS BODY

    --

    PROCEDURE xx_sample_prc (xx_sample_rec1 OUT xx_sample_table_rectype) IS

    BEGIN

    SELECT ename, empno

    IN xx_sample_rec1

    FROM scott.emp;

    END xx_sample_prc;

    END xx_sample_pkg;

    -------------------------------------------Execute----------------------

    DECLARE

    l_rec_type xx_sample_pkg.xx_sample_table_rectype;

    BEGIN

    dbms_output.put_line ('xx_sample_prc appeal');

    xx_sample_pkg.xx_sample_prc (l_rec_type);

    for l_rec in 1.l_rec_type.p_name.count

    loop

    dbms_output.put_line ('YZ' | l_rec_type.p_name (l_rec) |) » '|| l_rec_type.p_emp_id (l_rec));

    end loop;

    end;

    ---------------------------------------------------------------

    bb8c573a-6ca3-4d7c-90ed-e55c2df67201 wrote:

    But now, my question would be why the record type could not be used? My understanding is missing some concept between use of type type array collection record vs. Please specify.

    Do not confuse the folder with the collection.

    SY.

  • Using the record of decision in the Java API

    Hey all,.

    I work with an integration of Java of the OPA, and I'm curious to know how to exploit the record of decision by using the Java API for the information I'm after.

    Basic example:

    X = Maximum (A, B)

    In a record of decision, I see that A and B are used to determine X, but is there a way to know what is done with the API? I know its somewhere, I just need to get to work!

    Another example:

    X = (A - B) * C

    How can I retrieve what exactly happened in java using the API? Is this possible?

    Thank you!!!

    Dan

    Dan,

    Records of decision (code or xml) unfortunately do not go into that kind of detail. Records of decision describes what values are relevant and values assumed under influence, but they have no detailed calculation of information in them.

    It is not possible to do what you are trying to do.

    See you soon
    Frank

    Daniel Hager wrote:
    Hey all,.

    I work with an integration of Java of the OPA, and I'm curious to know how to exploit the record of decision by using the Java API for the information I'm after.

    Basic example:

    X = Maximum (A, B)

    In a record of decision, I see that A and B are used to determine X, but is there a way to know what is done with the API? I know its somewhere, I just need to get to work!

    Another example:

    X = (A - B) * C

    How can I retrieve what exactly happened in java using the API? Is this possible?

    Thank you!!!

    Dan

    Published by: frank.hampshire on April 10, 2013 10:42

  • Is it possible to use the record type or a PL/SQL table in the Select statement

    Hi all

    My requirement is that.
    I want to write a query and write a function, function, I want to return multiple columns at the same time in a Select statement.
    I select the return values in the Select no statement in a PL/SQL block.
    Is it possible to use the PL/SQL Table or Variable of Type record, or any other method in the statement Select?

    Please help me understand the solution.


    Kind regards

    830960 wrote:
    do we like it?

    In general, Yes, if the function is a function table, you can do something like:

    select  t.col1,
            t.col2,
            f.col1,
            f.col2,
            f.col3
      from  table_name t,
               table(some_table_function(param1,...paramN)) f
    /
    

    SY.

  • Can I use the recorder DVD SD-R6572M with my Satellite A80-117?

    Hello

    Can someone let me know if I can replace the DVD drive on my Satellite A80-117 with a SD-R6572M.

    Basically I'm looking for any information ragarding the compatibility, before buying the disc.

    Pointers are appreciated.

    Kind regards

    Hello

    I found information that these drives are compatible with your device:

    Read-only Drives
    Ext. Slim Line 24 x CD-ROM Drive PX1052E-1NMD
    External DVD - ROM Drive PA3401U-1DVD

    Writable discs
    CD-RW/DVD Rom Drive PA3438U - 1 external CD 2
    External DVD Super Multi Drive PA3402E-1DV2
    External DVD Super Multi Drive PA3454U-1DV2

    Unfortunately, I put t know if the SD-R6572M is compatible with the Satellite A80-11

    Good bye

  • animation using the recorded video

    I want to build my animation film using recorded video. I exported the audio only from first and imported into CA following your instructions. Thank you. Then, using AE, I an analysis of the video face recognition, data which, I understand it, is copied to the Clipboard. When I go to paste the data in my puppet, however, I get a message "Assertion failed! Am I missing a step? What is the only way to import data of face recognition? Thanks for your help.

    I tried ManyCam and find that it works very well for video and audio and to make one.

    A nice feature of CH is that you can record the movements of the head without the audio, and then later add any audio for the mouth.

  • c# how to connect to vcserver webservice using the sessionid / cookie

    " Is it possible to connect to the web service VcServer ' https://server.FQDN/SDK "using VimService2005.dll (VimObjects.cs)? "

    There are methods called LoginbySSPI which takes the user/pw and Login and none works with the session id.

    So far I managed to connect using cookies by using VimSoapService.25u2.dll - which is non-standard and get accessories object is too difficult to use.

    Any help is very appreciated. -pls also provide examples of code (beginner, sorry)

    Bernard

    SessionID is a valid string that must be once authenticated by the server and when reuse must be living in the session pool.

    Now to use sessionid, you need to use the API to login once to retrieve valid sessionid, you can then save it in a session file and later use the recorded session ID to fill your cookieString. For information about how to set this id in cookiestring, you should refer as a result of the LoadSession and SaveSession methods

    public void LoadSession (String fileName, String urlString) {}

    If (_service! = null) {}

    Disconnect();

    }

    _Service = new VimService();

    _Service. URL = urlString;

    _Service. Timeout = 600000;

    _Service. CookieContainer = new System.Net.CookieContainer ();

    BF BinaryFormatter = new BinaryFormatter;

    S Stream = File.Open (fileName, FileMode.Open);

    C cookie = bf. Deserialize (s) cookie;

    s.Close ();

    _Service. CookieContainer.Add (c);

    _Sic = service . RetrieveServiceContent (svcRef);

    _State = ConnectionState.Connected;

    If (AfterConnect! = null) {}

    AfterConnect (this, ConnectionEventArgs()) of new;

    }

    }

    public void SaveSession (String fileName, String urlString) {}

    Cookie cookie is _service. CookieContainer.GetCookies)

    New Uri (urlString)) [0];

    BF BinaryFormatter = new BinaryFormatter;

    S Stream = File.Open (fileName, FileMode.Create);

    BF. Serialize (s, cookie);

    s.Close ();

    }

    You should consult the latest SDK c# samples shipped long VI SDK for more details. Believe me, creating samples using vimService2005.dll is not at all confusing.

  • Reissue of links to the issue of the record

    Hello world.

    As a company, we transition to indesign for our documents. I was the driving force behind all this and have gigabites of terribly organized data. No seriously its all over the place.

    Quite enough TI crew want a record of strucured of properaly of all the date used as links to files.

    I have organized it for a new set of template files and it works fine. But I have a lot of very useful legacy things with their own records to link.

    I want to put these links in the newley created the record of relevant records, for example images of food in folder, images of flower in the folder of the flower.

    Of course these indesign files will then become their links, can I just connect to the first level of a folder and it checks in all other folders? Problem for me is I don't think once he hits the dirves companies all ork will of links as expected.

    I guess I plead for a workflow, its transformation in addition to a Mare that I thought!

    OK, it of not an unreasonable approach (and makes some sense in a collaborative working group). I suspect it will be painful to be well implemented. You should have asked above in the script, but if it is possible to point to the top-level folder and looking down through subfolders.

  • How can I use the audio/video Sockets front?

    I have a desktop Pavilion HPE - 480 t and can't find documentation anywhere on how to use the autio/video taken before.  When I plug in a device no software will automatically load.  Is there a bundled program that recognizes them?

    Hello azbard, you might be able to use the recording feature in Windows 7 to save from the back Line In jack.

    Plug your tape on the back Line In jack, and then go to the Control Panel, sounds and in the recording tab, check if the Line In Jack shows any connected device.

    If so, you can go to start ORB, all programs, accessories, Sound Recorder and see if you can save the tape.

    It can work either, but may be worth a try.

  • Can I get the total number of records that meet the conditions of a query using the Table API?

    Hello

    A < row > TableIterator is returned when I ask operations using the index of tables. If I want to get the total number of records, I count one by one using the returned TableIterator < row >.


    Can I get the total number of records directly meets the conditions of the query?

    I can get the total number of records directly the request of the meeting of the conditions of CLI using the command Global table - name tableName - count - index index-name-field fieldName - start startValue-end endValue.

    Can I get the same results using the Table API?

    I used MongoDB and NoSQL Oracle for about a year. According to the experience of the use of these dbs, I think mongoDB querying interface is powerful. In the contras, the query interface is relatively simple, which results is a lot of work that is usually a long time in the client side.

    Hello

    Counting records in a database is a tricky thing.  Any system that gives you an accurate count of the records will have a hotspot of concurrency on updates, namely the place where the counting is maintained.  Such a count is a problem of performance in addition to competitive access problem.   The problem is even more difficult in a system widely distributed such a NoSQL database.

    The CLI has overall command that counts, but does so by brutal force - iterate keys that correspond to the parameters of the operation.  This is how you must do this within the API.  There is not a lot of code, but you have to write.  You certainly want to use TableIterator TableAPI.tableKeysIterator (), because a key iteration is significantly faster than the iteration of lines.  Just one iteration and count.

    If you use TableAPI.multiGet () and a key with a touch of brightness full then, in fact, count the results as they are returned in a single piece (a list).

    Kind regards

    George

  • How to use the api to query / vcloud api to filter records by ID AdminVAppTemplate?

    I tried the following REST calls:


    Here, I tried to use the href of the vAppTemplate:

    https://VCD.dDEV/API/query?type=adminVAppTemplate & Filter = href is https://VCD.dDEV/API/vapptemplate-ed8aa4df-64be-454a-9acc-48ad25248092

    This means "com.vmware.vcloud.api.rest.parser.QueryParseException: Bad request: href unknown property name.

    Here, I tried to use the ID of the vAppTemplate (preferred method):
    https://VCD.dDEV/API/query?type=adminVAppTemplate & Filter = ID is urn:vCloud:vapptemplate:ed8aa4df - 64be-454-bis-9acc-48ad25248092

    https://VCD.dDEV/API/query?type=adminVAppTemplate & Filter = ID is ed8aa4df-64be - 454 a-9acc-48ad25248092

    the two returned "com.vmware.vcloud.api.rest.parser.QueryParseException: Bad request: name id unknown property.

    Here I was filtering by the parent organization (WORKS)
    https://VCD.dDEV/API/query?type=adminVAppTemplate & Filter = org is 0913b09e-7f78-4DE0-87cd-99f6cbf3227a

    Any thoughts on how I can sort by ID?  or same href?

    Hi jarhorn,

    Currently the query Service does not support filtering based on the href or id property, but you can use the entity resolver to help you since you already know that the property ID take a look at this article for more details - http://blogs.vmware.com/vsphere/2012/05/entity-resolver-in-the-vcloud-api.html

    FYI - we are aware of this limitation today with the query Service and it will be fixed.

    Thank you

  • The use of property in filters filters/range record geocode

    Hi all

    We have created a property called 'Place' to data type as "Geocoded" and we are able to use the same sort. And this will generate two dynamic properties by the name of "Kilometers_to_Location and"Miles_to_location". Is it possible to use these dynamic properties in our Records filters or filters in the range? We have obligation to filter products based on say less than 100 kms, 1000kms of the user's location and the sort not only on this basis.

    All the suggestions/help is appreciated.

    Concerning

    Shreyas

    Sarah,

    To answer your initial question, two dynamic properties geocodes are not persisted and are intended for informational purposes only (as show on a page in the user interface). However, you can use geocodes with filters in the range, then it could solve your problem. For more information, see Chapter 8 ("using line filters") in the "Basic Development Guide, available here:

    http://docs.Oracle.com/CD/E40176_01/MDEX.641/PDF/BasicDevGuide.PDF

    P.S. This is the forum for information discovery (MDEX, 7). You probably want to post on the OTN short experience Management Forum:

    https://forums.Oracle.com/Forums/Forum.jspa?forumid=1406

    Frank

  • Table filters break when using of text with the words "AND" or "OR".

    With the help of JDev 11.1.1.3.0

    Hello-

    The filters in the table seem to treat the words 'and' and 'or' differently when they are used in the filters in the table. Is it possible to change this behavior? I have a few sets of data where these words appear in the data. When the user performs a search on the data and uses the words 'and' or 'or' the filter no longer works. (He returned lines nil or returns all the rows.)

    Test case:

    1 create a filterable unalterable for the resources table. DEPARTMENTS table.
    2 set the Department name column to be case insensitive in its filtering:
                  <af:column sortProperty="DepartmentName" filterable="true"
                             sortable="true"
                             headerText="#{bindings.DepartmentsView1.hints.DepartmentName.label}"
                             id="c2" filterFeatures="caseInsensitive">
                    <af:outputText value="#{row.DepartmentName}" id="ot4"/>
                  </af:column>
    3. run the page.
    4. in my HR. Data REPRESENTATION, there is a service with the name "control and credit." In the service name filter, type
    a. 'control' and press ENTER - service of "control and credit" only comes
    (b) "control and" and press ENTER - only 'control and credit' Department appears
    c. 'control and credit' and press ENTER - ZERO departments appear.

    5. the Test cases for "GOLD". In the service name filter, type
    a. 'or' and press ENTER - displays all departments.


    I tried a few other words SQL in the filters but only 'AND' and 'GOLD' seems to break things.
    Is this a known bug?
    Is there a solution?

    Thank you for reading my question

    The list of documents http://docs.oracle.com/cd/E21764_01/web.1111/b31974/web_search_bc.htm#BABCCBCF 'AND' and 'GOLD' as 'Operators of Query-by-Example search criteria' are not text but the operators.
    You can try to join the text in the filter with single or double quotes and see, is that it treads in the form of text.

    Timo

  • Thunderbird says it can't find the records that my message filters use and are present in the list of folders.

    The error message reads:

    The record [which] is not found, then the filters associated with this file will be disabled. Verify that the folder exists, and that the filters to point to a valid destination folder.

    If I manually edit the disabled message rules and try a mail run, the same error messages come up.
    

    I have the problem solved. The database of the service provider Internet Mozilla for some reason any returns the name of the server 'imap.gmail.com' when the account is set up in Thunderbird.

    Manually configure as "photoscape", and filters work very well.

  • I want to record with &lt; alt &gt; &lt; s &gt; in the Exact program online. This function does not work. This is the first time I use this program with firefox.

    Question
    I want to record with < alt > < s > in the Exact program online. This function does not work. This is the first time I use this program with firefox.

    edit, escaped mod < s > in order to avoid the line through question

    A web page can be defined a "accesskey" for an item. Unlike IE/Chrome/Safari, who use the Alt key only, Firefox requires pressing Alt and Shift to activate the element. In other words, try

    ALT + SHIFT + S

    and see if it works.

    I don't know of any way to change this so that the change is not necessary. There may be an add-on?

Maybe you are looking for