Compare all records in a table

Hi,
I have this table
CRN Building Room
1 TH 100
2 TH 100
3 MC 200
4 MC 200
5 MC 100
6 DA 300
7 TH 100
Output:
Table Course
CRN Building Room
1 TH 100
2 TH 100
7 TH 100
3 MC 200
4 MC 200
I want to go through the whole table and and select 2 or more courses that have the same building and room#. I tried
select r.crn, r.building, r.room from course r
where exists (select 1 from course b where b.crn = r.crn and
b.building = r.building and b.room = r.room)
This didn't provide the results desired. Thanks for any help.

Something like this..
SQL> ed
Wrote file afiedt.buf
  1  WITH t as (select 1 as crn, 'TH' as building, 100 as room from dual union all
  2             select 2, 'TH', 100 from dual union all
  3             select 3, 'MC', 200 from dual union all
  4             select 4, 'MC', 200 from dual union all
  5             select 5, 'MC', 100 from dual union all
  6             select 6, 'DA', 300 from dual union all
  7             select 7, 'TH', 100 from dual)
  8  -- end of test data
  9  select *
10  from t
11  where (building,room) in (select building, room
12                            from t
13                            group by building, room
14*                           having count(*) > 1)
SQL> /
       CRN BU       ROOM
         7 TH        100
         2 TH        100
         1 TH        100
         4 MC        200
         3 MC        200
SQL>

Similar Messages

  • Incomplete Data on report (report does not show all records from the table)

    Hello,
    I have problem with CR XI, I'm running the same report on the same data with simple select all records from the table (no sorting, no grouping, no filters)
    Sometimes report shows me all records sometimes not. Mostly not all records on the report. When report incomplete sometimes it shows different number of records.
    I'm using CR XI runtime on Windows Server 2003
    Any help appreciated
    Thanks!

    Sorry Alexander. I missed the last line where you clearly say it is runtime.
    A few more questions:
    - Which CR SDK are you using? The Report Designer Component or the CR assemblies for .NET?
    - What is the exact version of CR you are using (from help | about)
    - What CR Service Pack are you on?
    And a troubleshooting suggestion:
    Since this works on some machines, it will be a good idea to compare all the runtime (both CR and non CR) being loaded on a working and non working machines.
    Download the modules utility from here:
    https://smpdl.sap-ag.de/~sapidp/012002523100006252802008E/modules.zip
    and follow the steps as described in this thread:
    https://forums.sdn.sap.com/click.jspa?searchID=18424085&messageID=6186767
    The download also includes instructions on how to use modules.
    Ludek

  • Delete all record in a table, the insert speed is not change.

    I have an empty table, and i insert a record need 100ms,
    when this table has 40,0000 record, i insert a record need 1s, this is ok, because i need do a compare based an index before insert a record, so more record, need more time.
    The problem is when i delete all record in this table, the insert time is still 1s, not reduce to 100ms.Why?

    Hello,
    Read through this portion of oracle documentation
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14220/logical.htm#CNCPT004
    The reason is still taking 1s, because when you inserted 400K record because HWM (The high water mark is the boundary between used and unused space in a segment.) moved up. And when you deleted all the records your HWM still at the same marker and didn't get to reset to 0. So when you insert 1 record it lookings for free space and after finding (generally a regular inserts got 6 steps it inserts data). If you truncate your table you and try it again it will be faster as your HWM is reset to 0.
    Regards

  • Comparing two records from different tables error.

    Hi folks!
    I have this PL/SQL Block.
    I want to compare the only one record from both tables to see if the content of them are equal or not, but I don't want to specified column by column to do that.
    Any idea?
    Thanks a lot in advanced,
    Abdel E. Miranda S.
    Panama
    declare
    cursor c_aems_prueba is
    select nombre, direccion, telefono, limite, seq
         from aems_prueba;
    cursor c_aems_testing is
    select nombre, direccion, telefono, limite, seq
         from aems_testing;
    vc_aems_prueba c_aems_prueba%rowtype;
    vc_aems_testing c_aems_testing%rowtype;
    vt_aems_prueba aems_prueba%rowtype;
    vt_aems_testing aems_testing%rowtype;
    begin
    insert into aems_prueba
    values('ABDEL MIRANDA', 'PAITILLA', '215-3411', 1000, 1);
    insert into aems_testing
    values('ABDEL MIRANDA', 'PAITILLA', '215-3411', 1000, 1);
    commit;
    open c_aems_prueba;
    fetch c_aems_prueba into vt_aems_prueba;
    open c_aems_prueba;
    fetch c_aems_prueba into vt_aems_testing;
    if vt_aems_prueba = vt_aems_prueba
    then
         dbms_output.put_line('son iguales las variables, si funciona la comparacion de dos estructuras');
         else
         dbms_output.put_line('no son iguales las variables, no funciona la comparacion de dos estructuras');
    end if;
    close c_aems_prueba;
    close c_aems_testing;
    end;

    Satyaki De,
    Java is involving because an Outsourcing new project. The outsourcing company is developing the new application using JSF which invoke an interface java method [depending of the operation: select, update, insert] and them invoke the PLSQL API to precess tha operation.
    In the case I already wrote here, the issue is this:
    The user search for a specific data using the interface. The java method send a request for these operation through the API. the PLSQL process the request and return a beam, with all the column the user look for.
    The user see the information in the application windows. Assuming the user wants to change some data, he modify just one field [lets say telephone number] and press the update button. The application process the request using a different method, which invoke a different function within the PLSQL API.
    Once the information is returning to the API, I must know if at least one field change its value. So I was thinking to get the beam with the data before it was changed and compare it with the beam with the changing data.
    If current_beam = new_beam
    then
    update
    else
    no change to process
    end if;
    Any idea.

  • How to SELECT ALL records of a TABLE VIEW in the BSP page

    Hi All,
    In the BSP portal, I am displaying some data(multple records) in the form of a table using the BSP TAG <htmlb:tableView>. I wrote the logic in the 'VIEW' of the BSP application which will be triggered by the controller. I have used the attribute selectionMode = "MULTISELECT" to have a Check Box to select a row.
    My requirement is to have a button/checkbox on the first column of the header of the table view. By clicking on this, it should select/desect all the records of the table. Could someone please help me how to do this? What attribute I should use in the tableview to get the button in the header row of the table and how to select all the records of the table.?
    Please provide your valuable inputs.
    Thanks & Regards,
    Paddu.

    Select all / Deselect all functionality when onRowSelection is there

  • Deleting all Records in a Table

    I have an table that is populated as users login and move through an application so I can tell what they are doing as well as who is logged in. Once and a while I would like to empty this table of all records once I have exported the audit data. I would like to do this from the same page that I have based a tabular form on. Can any suggest the easiest way to achieve this?
    Could the following SQL be used somewhere to do the job?
    delete CREATE_BY, CREATE_ON, ACTION, SUBJECT from AUDIT;
    Kind Regards,
    Steve

    Hi,
    Even with TRUNCATE (which is what I use to do this sort of thing), you have to bear in mind what happens to indexes on the table (and, I'm assuming that there will be sizable indexes involved) and the time it takes to clear these out on top of clearing out the table's data. From advice I've seen on the SQL forum, I do something like the following in PL/SQL to clear a table:
    BEGIN
    EXECUTE IMMEDIATE 'ALTER INDEX TABLENAME_IDX1 UNUSABLE';
    EXECUTE IMMEDIATE 'TRUNCATE TABLENAME';
    EXECUTE IMMEDIATE 'ALTER INDEX TABLENAME_IDX1 REBUILD NOLOGGING';
    COMMIT;
    END;Andy

  • Create infopath form contain all records of particular table

    Hi,
    It has resolved my above issue.
    I want to create one sharepoint list connected with database and when i click on add new item, it should display infopath form. 
    I am able to show infopath form on click of 'Add new item' but sharepoint list not containing all records of that particular table.So how can i get all the records of my table.It is possible using external list. But in that case, can i show infopath form?
    Please suggest.
    Please help to solve the issue.
    Thanks & Regards
    Rajni

    Hi Stark,
    Thanks for your response.
    Actually here i am talking about rows in the particular table.
    I want to show all rows in sharepoint list.
    So,is it possible in sharepoint?
    Please guide.
    Thanks in advance!
    Regards
    Rajni

  • Form does not display all records from table

    Hi guys
    I modified one form that was based on a signle DB table. I removed certain fields from the table and added some extra fields to that table. Then based on the new table I also modified the form and removed the text items related to old fields in the table and added new text items pointing to the new fields now. II have checked all the new items properties and they have don't seem to be wrong or so. But now the problem is the form does not display all the records from the table. before it used to display all records from the table when qureied but not now. It only certain records from the table containing all new data and also old data but the form does not display other records though I don't see any obvious discrepancy. Remember that the before doing the modifications, I have table back for the old, created another table that contained new records for the new fields, and then I inserted the old records and updated the new table data in the new table with these new table values. So this way I have got my new table. Could someone help why the new modified form fails to display all records from the new table updated table though it display some of them successfully.
    Any help will be appreciated.
    Thanks

    hi
    Set the block property of "Query All Records" to "YES"
    hope it will work.
    Faisal

  • How can i get all the records from three tables(not common records)

    Hi
    I have four base tables at R/3-Side. And i need to extract them from R/3-Side.
    And i dont have any standard extractor for these tables .
    If i create a 'View' on top of these tables. Then it will give only commom records among the three tables.
    But i want all the records from three base tables (not only common).
    So how can i get the all records from three tables. please let me know
    kumar

    You can create separate 3 datasources for three tables and extract data to BW. There you can implement business login to build relation between this data.

  • Iterate through all the records in a table using Java API

    Hi All,
    What is the easiest way to iterate through all the records in a given table using Java API? I cannot find any methods that will return all records in a table and the only way I can use is to perform a free form search with a condition that is always true. The code works but is pretty ugly. Is there an alternative to this approach?
    Thanks!
    Kenny

    Hi Kenny,
    You can construct a new Search object with your table's code name, a new ResultSetDefinition object for your table and just execute this search using the GetResultSet method of CatalogData.
    Please look at the following code:
    Search search = new Search(<code name of your table>);
    ResultSetDefinition rsd = new ResultSetDefinition(<code name of your table>);
    rsd.AddField<code name of a field>);
    rsd.AddField(<code name of a field>);
    String sortField = <code name of your sort field>;
    boolean sortAscending = true;
    int page = 0; //page number
    A2iResultSet rs = <your CatalogData object>.GetResultSet(search, rsd, sortField, sortAscending, page);
    for (int i = 0; i < rs.GetRecordCount(); i++)
        Value fieldValue = rs.GetValueAt(i, <code name of a field>);
    Hope this helps,
    Nir
    PS - I really recommend you to start using the new API, as it is much more efficient and straight-forward.

  • How can i use BAPI to insert a few records into standard table usobt_c

    I needed to compare the records of this table on two different systems and update the records that were in system A but not in system B into system B. Please give your inputs.

    Hi,
    First of All try to Explain your Question first.
    This is a general question without mentioning the Table you want to Update.
    Please give the details before posting a question  so it will help people to understand your Problem.
    Regards
    Sandipan

  • How to update Records of SAP table from .CSV file

    Hi,
    I have written a code which takes a data from (,) delimited CSV file and adds it into the Internal table.
    Now I want to update the all fields in SAP table with the Internal table.
    I want to use Update statement.
    Update <table Name> SET <field needs to update> WHERE connditon.
    I don't want to iterate through thousand on record in sap table to check the where condition.
    Could you please tell me how to do it.

    Hi. I thing you will not workaround the iterating of the internal table.
    You can pre-load all the records into another internal table
    check lt_csv[] is not initial. " important, otherwise next select would read all records of the table
    select .... into lt_dbitab for all entries in lt_csv where key-fieds = lt_csv-key_fields...
    check sy-subrc eq 0 and lt_dbitab[] is not initial.
    then do in-memory update of the it_dbitab
    loop at it_dbitab assign <fs>.
      read table lt_csv assign <fs_csv> with key ... " lt_csv should be sorted table with key, or you should try to use binary search
      if sy-subrc eq 0.
        ...change required lt_dbitab fields: <fs>-comp = <fs_csv>-comp...
      endif.
    endloop.
    ant then you can do mass-update
    update dbtab from table lt_dbitab.
    From performance view, this solution should be much faster than iterating lt_csv directly and updating every single database record
    Br
    Bohuslav

  • Delete the parent records and child table records at a time

    hi all;
    I am facing the pbm like to delete the all records in child table and corresponding records in parent table at a time. so I want to delete the all the records in child table and corresponding parent records in parent table by using single SQL query. plz help me
    Thanks in advance

    You want to use one single SQL statement to delete the child records in a table and the corresponding master records in the master table??
    That's not quite possible with a single SQL, of course unless you are talking about Oracle Forms, where you have a relation and set the delete behavior to Cascading, like said in the above posts.
    Tony

  • Personnel Admin AdHoc Query not retrieving all records

    Hi, I recently added a custom info type to a copy of the SAP ad hoc query for Personnel Admin by using the menu path in SQ02>Edit>Change Infotype selection . The query is picking up the new info type and runs fine but does not retrieve all records from the table for a given personnel id. It only retrieves 1 record per id.
    Has anyone dealt with this before and have an easy/quick fix for this?

    Have other users try the query, preferably a user with end user authorization.
    I've had this issue before, I'm an IT person and I customized a Standard infoset.
    During testing, I'm only getting 1 (in my case) Insurance record per employee.
    The end user can see multiple record per employee.
    Btw, did you customize a Global or a Standard Infoset?
    Regards,
    Olekan

  • Automatic start workflow for ALL records

    Hi Experts,
    Does anyone know a way to start workflow automatically for ALL records without human interference?
    I want to start workflows every day. For instance to recalculate, re-validate, re-assign or syndicate ALL records of a table.
    Kind regards,
    Job Jansen

    Hello Job Jansen
    I suppose recalculate and validate all recodrs once a day don't make sense when that records is the same
    and records wasn't changing
    However, you can use Autolaunch = Threshold with Max Time = 24 hour(for example)
    workflow will fire when Max Time say greater then time last launched job.
    And few another ways:
    1) you can use task sheduler for launch import manager and turn autolaunch workflow when it do import
    2) turn automatic import process(MDIS) once a day and use workflow for add records
    3) developed Java application which used MDM JAVA API for start workflow
    Regards
    Kanstantsin

Maybe you are looking for

  • Can't add rows to a table in Pages 5.1

    I started my table in Numbers but it defaults to huge margins top bottom and on the sides so I can't get much on one page and it won't let you change the margins - one of the huge advantages Excel has. So I copied and pasted part of my table into Pag

  • Phone doesn't display music

    I'm currently using Nokia 5800 XpressMusic. I've bought it barely two months ago. All was fine until I manually dragged/dropped some music prom my PC via USB cord. Now whenever I go to the Gallery/Songs it says "No Songs". I have tried everything: re

  • Why no fade in from black when clip without head handle is adjacent to ...?

    There seems to be a lot of workarounds and unintuitive ways of doing things in FCP. I'm trying to understand if it's something I don't know or if the developers of FCP are lazy to make things just work. I'd like to know the reasoning for not allowing

  • Unable to completely install Adobe Flash Player 10.3

    Hi all, I need some help here. I have uninstalled previous versions of the flash player and tried installing the latest version. But the installation stopped at 50% and stated "Error: Application Currently In Use". I tried re-installing again and aga

  • Macbook hard drive fail....I think?

    I have a Macbook that when booted just displayed a folder icon. Thru searching I believed the hard drive failed. 80gb drive fails "verify disk" so I ran "repair disk". It says it repairs but always fails again on verify. So I purchased a new hard dri