What is correct query ?

I have two tables: tmp and tmp1. the output should be, for each cno in tmp, its pno should be ALL in the tmp1. The correct output should be '1111'.
I have written a query based on 1111, it works. But how could I extend to 2222, 3333 .... ? what is correct query ?
Thanks.
select * from tmp;
CNO                    PNO                   
1111                   10506                 
1111                   10507                 
1111                   10508                 
1111                   10509                 
2222                   10601                 
2222                   10701                 
3333                   10800                 
3333                   10900                 
8 rows selected
select * from tmp1;
PNO                   
10506                 
10507                 
10508                 
10509                 
10701                 
10800                 
6 rows selected
select * from tmp where
cno = 1111
and
not EXISTS(select pno from tmp  where cno = 1111 minus select pno from tmp1)
CNO                    PNO                   
1111                   10506                 
1111                   10507                 
1111                   10508                 
1111                   10509                 
4 rows selectedEdited by: user533361 on Sep 27, 2009 1:47 PM

with tmp as (
             select 1111 cno,10506 pno from dual union all
             select 1111,10507 from dual union all
             select 1111,10508 from dual union all
             select 1111,10509 from dual union all
             select 2222,10601 from dual union all
             select 2222,10701 from dual union all
             select 3333,10800 from dual union all
             select 3333,10900 from dual
    tmp1 as (
             select 10506 pno from dual union all
             select 10507 from dual union all
             select 10508 from dual union all
             select 10509 from dual union all
             select 10701 from dual union all
             select 10800 from dual
select  cno
  from  tmp t1,
        tmp1 t2
  where t1.pno = t2.pno(+)
  group by cno
  having count(t1.pno) = count(t2.pno)
       CNO
      1111
SQL> SY.

Similar Messages

  • Buffer Hit Ratio % -- Whats the right query ?

    Whats the right query to track Buffer Hit % ;
    Using this :
    prompt BUFFER HIT RATIO %
    prompt ===============
    select 100 * ((a.value+b.value)-c.value) / (a.value+b.value) "Buffer Hit Ratio"
    from v$sysstat a, v$sysstat b, v$sysstat c
    where
    a.statistic# = 38
    and
    b.statistic# = 39
    and
    c.statistic# = 40;
    Buffer Hit Ratio
    99.9678438
    However, using this :
    Select
    Round((Sum(Decode(name, 'consistent gets',value,0)) +
    Sum(Decode(name, 'db block gets',value,0)) -
    Sum(Decode(name, 'physical reads',value,0))) /
    (Sum(Decode(name, 'consistent gets',value,0)) +
    Sum(Decode(name, 'db block gets',value,0)) ) * 100, 4)
    from V$sysstat;
    Comes up as : 67.7069 %
    So which is the right one ?
    Thanks.

    user4874781 wrote:
    Well, I recently joined this organisation and that was the script that was used since long to check Buffer Hit Ratio%.
    But when I ran a TOAD report, using the other query, the value came up different.
    So am confused .. Whats the difference and which is the right one ?
    Try running the following query:
    select
            statistic#, name
    from
            v$sysstat
    where
            statistic# in (38,39,40)
    or      name in (
                    'consistent gets',
                    'physical reads',
                    'db block gets'
    ;The you will understand the point the previous answer was making. It's a bad idea to rely on things like the statistic# being consistent across different versions of Oracle - names tend to be safer.
    But neither query is correct. If you want any sort of vaguely meaningful "buffer cache hit ratio", you should be quering v$buffer_pool_statistics. See also: Re: Testing of buffer cache reveals these results: and http://jonathanlewis.wordpress.com/2007/09/02/hit-ratios/
    Regards
    Jonathan Lewis
    http://jonathanlewis.wordpress.com
    http://www.jlcomp.demon.co.uk
    "The greatest enemy of knowledge is not ignorance, it is the illusion of knowledge." Stephen Hawking.

  • Correct Query For EJB

    I have such classes
    Entity bean
    @Entity(name = "Actor")
    @Table(name = "actor")
    public class Actor extends DomainObject{
        @Id
        @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "actor_id_seq")
        @Column(columnDefinition = "id")
        private Long id;   
        @Embedded
        @AttributeOverrides({
            @AttributeOverride(name="firstName", column=@Column(name = "firstname", nullable = false)),
            @AttributeOverride(name="lastName", column=@Column(name = "lastname", nullable = false))
        private PersonalInfo personalInfo;
       // getters and setters here
    }Here is an embedded class
    @Embeddable
    public class PersonalInfo {
        private String firstName;
        private String lastName;
        //getters and setters
    }And here is a stateless bean
    @Stateless
    @Remote(AccountService.class)
    public class AccountServiceBean implements AccountService {
        @PersistenceContext
        private EntityManager manager;
        public Actor findActorByFirstName(String firstName){
            Query q = manager.createQuery("SELECT actor FROM Actor actor WHERE actor.firstName = :firstName"); //!!!HERE
            q.setParameter("firstName", firstName);       
            return (Actor) q.getSingleResult();
    }Can anybody say, what is the reson why createQuery method doesn't work? Or maybe, somebody can help me with a correct query.
    I use Sun Application Server 9. In log i see such error
    javax.ejb.TransactionRolledbackLocalException: Exception thrown from bean; nested exception is: java.lang.NullPointerException
    java.lang.NullPointerException
         at com.sun.enterprise.util.EntityManagerWrapper.createQuery(EntityManagerWrapper.java:521)
         at net.sourceforge.openejforum.services.engine.ejb3.AccountServiceBean.findActorByFirstName(AccountServiceBean.java:40)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:585)
    ...Thank you
    Message was edited by:
    awep

    You can try this in your query:
    Query q = manager.createQuery("SELECT actor FROM Actor actor WHERE actor.personalInfo.firstName = :firstName");
            q.setParameter("firstName", firstName);    I hope this can help you.

  • What is the query for Accounts Payable Trial Balance (APXTRBAL) in 11.5.10?

    Hi Guys,
    What is the query for Accounts Payable Trial Balance (APXTRBAL) in 11.5.10?
    I have to write an AP Invoice Aging Report in Discoverer to show all unpaid invoices that have been transferred into GL... Business wants it to match one-to-one with the AP Trial Balance standard report...
    Business wants to run the report for any date in a past...
    The report has two parameters:
    As Of Date - the same as As of Date for the AP Trial Report
    Trial Balance Run Date - the date when Trial Balance was run...
    Conditions are:
    TRUNC(Invoice Date) <=TRUNC(NVL(TO_DATE(:As Of Date),SYSDATE))
    TRUNC(NVL(Payment Date,'01-JAN-5000')) > TRUNC(NVL(TO_DATE(:As Of Date),SYSDATE))
    TRUNC(Invoice Creation Date) <= TRUNC(NVL(TO_DATE(:Trial Balance Run Date),SYSDATE))
    Distr Accounting Date <= TRUNC(NVL(TO_DATE(:As Of Date),SYSDATE))
    NVL(Distr Creation Date,Invoice Creation Date) <= TRUNC(NVL(TO_DATE(:Trial Balance Run Date),SYSDATE))
    Show_Flag = 'YES', where:
    Show_Flag = CASE WHEN ( NVL(Cancelled Date,'01-JAN-1901') > NVL(:As Of Date,SYSDATE) AND NVL(Inv Amount Aud,0) = 0 ) THEN 'YES' ELSE ( CASE WHEN NVL(Inv Amount Aud,0) = 0 THEN 'NO' ELSE 'YES' END ) END
    There is a difference between the logic of my report, and the logic of AP Trial Balance...
    Could you please advise what I'm missing?
    Thanks,
    Iana

    What is the query for Accounts Payable Trial Balance (APXTRBAL) in 11.5.10? You can get the code by opening the report in Reports Builder and get the query.
    Or, enable trace/debug as per (FAQ: Common Tracing Techniques within the Oracle Applications 11i/R12 [ID 296559.1]).
    Thanks,
    Hussein

  • Just started MobileMe.  Struggled with the setup of iCal but eventually got everything working fine for about a day.  Then I started receiving an iCal error message stating that the URL was wrong.  Of course, sync no longer works.  What is correct URL?

    Just signed up for MobileMe.  Had a little difficulty setting up iCal but eventually got everything working.  Whether posting to iCal on my Mac Book or iPhone, sync seemed to be working fine for about a day.  Then suddenly when I opened iCal on my Mac Book, I would receive the following iCal error message:
    "The calendar https://cal.me.com/calendar/calendar/principals/users/1.1117025442/ was not found on the server. Make sure the URL is correct."  I know where it is located but because I did not enter the URL when I set up MobileMe/iCal, I don't know what the correct URL should be.

    Mike,
    Welcome to Apple Support Communites.
    Review; MobileMe: Setting up iCal for the new MobileMe Calendar, and post back with further questions.

  • I recently purchased a shutter release remote for my IPAD camera but the cord is only three feet long.  I purchased a 3 banded AV extension but it doesn't work.  Can anyone tell me what the correct extension cable is and where I can find one?  Thanks.

    I recently purchased a shutter release remote for my IPAD camera but the cord is only three feet long and I need an extension cord.  I purchased a 3 banded AV extension but it doesn't work.  I have been told that I need an extension cord that has AV and Mic to enable the remote shutter release to work with the extension cord.  Can anyone tell me what the correct extension cable is and where I can find one?  Thanks.

    Greetings,
    I've never seen this issue, and I handle many iPads, of all versions. WiFi issues are generally local to the WiFi router - they are not all of the same quality, range, immunity to interference, etc. You have distance, building construction, and the biggie - interference.
    At home, I use Apple routers, and have no issues with any of my WiFi enabled devices, computers, mobile devices, etc - even the lowly PeeCees. I have locations where I have Juniper Networks, as well as Aruba, and a few Netgears - all of them work as they should.
    The cheaper routers, Linksys, D-Link, Seimens home units, and many other no name devices have caused issues of various kinds, and even connectivity.
    I have no idea what Starbucks uses, but I always have a good connection, and I go there nearly every morning and get some work done, as well as play.
    You could try changing channels, 2.4 to 5 Gigs, changing locations of the router. I have had to do all of these at one time or another over the many years that I have been a Network Engineer.
    Good Luck - Cheers,
    M.

  • What is correct method to deploy cluster aware technology using HA VMs?

    Dear all, 
    I recently had experience creating Hyper-V Server 2012 cluster. This allows for deploying a highly available virtual machine. That's fine. The business machine (virtual machine) becomes highly available. This includes an existing VM enabled to be highly
    available or a new VM installed into cluster from scratch.
    On the other hand; we have cluster aware applications (SQL Server, SCVMM etc.) which are installed in clustered OS (Windows 2008 R2 Enterprise edition which has failover clustering service) . 
    Just for clearing concept; what is correct way of deploying a cluster aware technology (SQL Server, SCVMM) in the scenario where the underlying OS; running in VM(s) can be made highly available. 
    Method 1:
    Create simple non clustered VM, install cluster aware application (SQL Server e.g.). Make this VM highly available using Hyper-V cluster.  (This seems to be clustering the VM running cluster aware application, not the cluster ware application; which
    requires clustering.)
    Method 2:
    Create HA-enabled  VM onto Hyper-V Servers cluster; install cluster aware application within this HA-enabled VM.   (This again; the underlying OS/VM is clustered first, the cluster aware application (SQL server or others) how would it leverage
    the cluster?)   
    Please shed light on what is correct method. In both cases it seems the VM running the cluster aware application; is made highly available; meaning leveraging clustering. What about clustering the application
    itself? The objective is to be able to not only make the VM highly available; but also deploy clustered SQL Server  or other cluster aware technology using such HA VM.
    Regards, 
    Shahzad.

    Dear all, 
    I recently had experience creating Hyper-V Server 2012 cluster. This allows for deploying a highly available virtual machine. That's fine. The business machine (virtual machine) becomes highly available. This includes an existing VM enabled to be highly
    available or a new VM installed into cluster from scratch.
    On the other hand; we have cluster aware applications (SQL Server, SCVMM etc.) which are installed in clustered OS (Windows 2008 R2 Enterprise edition which has failover clustering service) . 
    Just for clearing concept; what is correct way of deploying a cluster aware technology (SQL Server, SCVMM) in the scenario where the underlying OS; running in VM(s) can be made highly available. 
    Method 1:
    Create simple non clustered VM, install cluster aware application (SQL Server e.g.). Make this VM highly available using Hyper-V cluster.  (This seems to be clustering the VM running cluster aware application, not the cluster ware application; which
    requires clustering.)
    Method 2:
    Create HA-enabled  VM onto Hyper-V Servers cluster; install cluster aware application within this HA-enabled VM.   (This again; the underlying OS/VM is clustered first, the cluster aware application (SQL server or others) how would it leverage
    the cluster?)   
    Please shed light on what is correct method. In both cases it seems the VM running the cluster aware application; is made highly available; meaning leveraging clustering. What about clustering the application
    itself? The objective is to be able to not only make the VM highly available; but also deploy clustered SQL Server  or other cluster aware technology using such HA VM.
    Regards, 
    Shahzad.
    With SQL Server both M1 and M2 are by far the best solutions. See guest VM cluster is non-optimal as SQL Server works better with own clustering features (AlwaysOn, see link below). And HA would make VM re-boot on another physical host so there would be
    both downtime and potential data loss. Run SQL Server in a pair of VMs on a different physical hosts, configue AlwaysOn (use failover SMB share as a witness) and you'll be fine. See:
    Overview of AlwaysOn Availability Groups (SQL Server)
    http://technet.microsoft.com/en-us/library/ff877884.aspx
    How to Build SQL Server
    2012 AlwaysOn Hyper-V Virtual Machines
    http://social.technet.microsoft.com/wiki/contents/articles/6198.how-to-build-sql-server-2012-alwayson-hyper-v-virtual-machines-for-demos-emu-build.aspx
    SQL Server 2012 AlwaysOn High Availability and Disaster Recovery Design Patterns
    http://blogs.msdn.com/b/sqlcat/archive/2013/11/20/sql-server-2012-alwayson-high-availability-and-disaster-recovery-design-patterns.aspx
    Also the best place to ask about SQL Server High Availability is dedicated MSFT group here:
    SQL Disaster Recovery Forum
    http://social.technet.microsoft.com/Forums/sqlserver/en-US/home?forum=sqldisasterrecoveryHope
    this helped :)
    StarWind VSAN [Virtual SAN] clusters Hyper-V without SAS, Fibre Channel, SMB 3.0 or iSCSI, uses Ethernet to mirror internally mounted SATA disks between hosts.

  • How to get into BIOS of Sat P200D? What is correct temp for CPU/VGA load?

    I tried everything, pressing ESC after power-up,F1, ESC/F1, F2....i cannot get into the bios.
    What is the proper procedure to get into the BIOS? I used the latest BIOS 1.70 from Toshiba homepage, i remember i didn't have this problem with the older bios.
    Furthermore, what are correct temps for the CPU under extreme load as well as VGA testing with OCCT/Furmark or everest?
    If i run OCCT (extreme CPU stress test) i am getting some extreme numbers up to 95 degree on the CPU...
    Thanks!

    *SOLVED!!!*
    It was indeed the case that any standard VGA resolution (like bios screen and bootup screen) was not displayed on the laptop!
    Thats why i only saw a black screen!
    I plugged an external monitor on it, and i see i am actually in BIOS.
    So i went into the BIOS (using the other monitor) and changed the the setting "Analog + External", and now it works and i also have the toshiba logo back and everything

  • What are the query types,Objects CRM provides for third party

    What are the query types,Objects provided by the CRM so that it can be called by third party for integartion pupose.

    First, that statement - and those materials - refer to the "legacy" StreamInsight query/adapter model. They do not refer to how things work with the Reactive model introduced in version 2.1. Specifically, it talks about Dynamic Query Composition (DQC).
    You cannot use a deployed Observable in another instance of StreamInsight. You may be able to use them across applications in the same instance - off the top of my head, I'm not sure. I'm getting ready to get on a plane but will take a look at it later.
    Typically, however, applications act as containers (comparable to .NET AppDomains) so I don't think that you'd be able to do this easily. That said, the code and assemblies
    can be reused across multiple instances/applications. You would have separate instances of the classes involved but you would be able to reuse the query logic. That's a common use case.
    Can you be more specific about your use case and what you are trying to accomplish here? It's possible that there are alternative ways to do what you are trying to do.
    DevBiker (aka J Sawyer)
    Microsoft MVP - Sql Server (StreamInsight)
    If I answered your question, please mark as answer.
    If my post was helpful, please mark as helpful.

  • What is correct way to run python script in build phases

    in xcode 4.6  build phases i have added a run script
        python build.py
        exit
    when i build project it never finishes it keep on saying running custom shell script
    what is correct way to run python script in build phases ?

    /usr/bin/python build.py
    exit
    still the issue remians.

  • HT3258 What is correct update or upgrade for Mac OSX v 10.5.8? Also can't use sites without updates on firefox & safari. Auto update shows none available?

    What is correct update or upgrade for Mac OSX v 10.5.8? Also can't use sites without updates on firefox & safari. Auto update shows none available?

    Click here.
    (89934)

  • HT201328 i havent received a message from carrier yet, but what is correct procedure to unlock iphone 5....

    i havent received message from carrier yet, but what is correct procedure to unlock iphone 5

    Read here:
    http://support.apple.com/kb/HT5014

  • What is correct billing type to generate invoice ?

    As per our deployment consultant for Debit memo with billing type ZL2 we cannot create Excise invoice through T-code J1IIN and and billing type ZF2 is required.
    But i also heard it is not possible to force a ZF2 for a debit note ZL2 and not the correct process according SAP standard.
    Can you please clarify what is correct approach

    Hi,
    if you want to change J1iin - excise invoice Document type - follow below mentioned Path - give new document type for billing
    SPRO
              Logistics - General
                             Tax on Goods Movements
                                            India
                                                  Maintain Company Code Settings
                                                           11th Column give New Document type ZF2 or ZL2
    save
    Mahesh   

  • What is the query to update table in ejb3.0

    Hi Friends,
    I am developing one application using ejb3.0 in Netbeans IDE 6.7.1 with Glassfish Application server.
    To insert data we use "entitymanager.persist(Insert insert);"
    To retrieve all data from table "entitymanager.createQuery("")'
    In the same way what is the query for update?
    Could you please help me.
    Thanks in advance.

    [the answer|http://lmgtfy.com/?q=java+jpa+udpate+query]

  • What is a query to know what Privileges a user is having?

    what is a query to know what Privileges a user is having?
    for both DBA and System....
    Thanks in advance.

    This is a complicated question. Because roles have privileges. And those privileges can be roles. So the level of nesting can get quite complex quite quickly.
    So the best thing for you to do would be to check out Pete Finnegan's find_all_privs.sql script, which does the whole thing for you.
    Cheers, APC

Maybe you are looking for