Any difference between the two queries

Hello

Could someone please help me to see if the following two queries return different results?

Thank you

Query A

SELECT A.BATCH_NO,

A.BU_CODE,

SUM (A.AMOUNT) AMOUNT

FROM TABLE_A HAS

WHERE A.BU_CODE = 20

AND G_DATE BETWEEN TO_DATE (JANUARY 31, 2013 ',' MON-DD-YYYY "")

AND TO_DATE (MARCH 31, 2013 ',' MON-DD-YYYY "")

--

AND A.BATCH_NO IN (SELECT BATCH_NO

TABLE_A B1

WHERE B1. BATCH_NO = A.BATCH_NO

AND B1. BU_CODE = A.BU_CODE

AND B1. ' CODE_P = ' 06-01-01-000.

AND B1. FROM_FLAG = 'FROM '.

)

AND A.BATCH_NO IN (SELECT BATCH_NO

FROM TABLE_A B

WHERE B.BATCH_NO = A.BATCH_NO

AND B.BU_CODE = A.BU_CODE

AND B1.ORG = '10'

)

A.BATCH_NO GROUP,

A.BU_CODE

;

Query B

SELECT A.BATCH_NO,

A.BU_CODE,

SUM (A.AMOUNT) AMOUNT

FROM TABLE_A HAS

WHERE A.BU_CODE = 20

AND G_DATE BETWEEN TO_DATE (JANUARY 31, 2013 ',' MON-DD-YYYY "")

AND TO_DATE (MARCH 31, 2013 ',' MON-DD-YYYY "")

--

AND A.BATCH_NO IN (SELECT BATCH_NO

TABLE_A B1

WHERE B1. BATCH_NO = A.BATCH_NO

AND B1. BU_CODE = A.BU_CODE

AND B1. ' CODE_P = ' 06-01-01-000.

AND B1. FROM_FLAG = 'FROM '.

AND B1.ORG = '10'

)

A.BATCH_NO GROUP,

A.BU_CODE

;

Hello

These 2 requests are not the same.  Depending on your data, query A, can select more lines as searching for B.

I do not have access to your table, so I'll give an example of using the table scott.emp.

The following 2 queries look like your 2 questions:

SELECT deptno - query A
work
sal
FROM scott.emp m
WHERE deptno IN ((in English only)
SELECT sj.deptno
FROM scott.emp sj
WHERE sj.deptno = m.deptno
AND sj.job = 'CLERK '.
)
AND (IN) deptno
SELECT ss.deptno
FROM scott.emp ss
WHERE ss.deptno = m.deptno
AND ss.sal > 1200
)
;

SELECT deptno - query B
work
sal
FROM scott.emp m
WHERE deptno IN ((in English only)
SELECT s.deptno
FROM scott.emp s
WHERE s.deptno = m.deptno
AND s.job = 'CLERK '.
AND s.sal > 1200
)
;

The results of A query are all 14 rows in the table, but query B produces only 3 lines of deptno = 10.

Query A looking for departments who have committed and the departments that have sal > 1200.  If a line in the Department has job = 'CLERK' (regardless of the sal), and another line was sal > 1200 (regardless of the work), while the Department meets both criteria.

Query B is looking for federal departments who have committed that sal is over 1200.  Two criteria must be met on the same line.

Tags: Database

Similar Questions

  • Trying to get the 'difference' between the two tracks

    What I'm trying to accomplish is the following: I have an audio track of a voice-over with a music bed located underneath. I also itsself Chamber music, without the voiceover. I want only the share of voice. Is it possible that I can "cancel out" the part of the music or get the difference between the two tracks (just the voice part)? It seems that there should be a way to do it, but for the life of me I can't figure out how do it!

    Any advice?

    There you go...

    http://www.libinst.com/audio%20DiffMaker.htm

    Unfortunately, the above utility has been abandoned by its author.  :-(

    It only works on Windows XP, to start...

    -RFH

  • Any difference between the separate function and aggregation in sql query cost?

    Hello
    I've run many models sql stmts - such as:
    one) using a single table
    (b) using the two tables, using simple joins or outer joins

    but I didn't notice a difference in sql stmts in cost and implementation plan...
    In any case, my colleague insists on only using the aggregate function is less expensive compared to
    separate... (something I've not confirmed, that is why I believe that they are exactly the same...)

    For the situation described above under 1 sql... We could for example use
    select distinct deptno
    from emp
    select count(*), deptno
    from emp
    group by deptno
    select distinct owner, object_type from all_objects
    select count(*), owner, object_type from all_objects
    group by owner, object_type
    Have you ever found no difference between the two...?

    Note: I use Ora DB 10g v2.

    Thank you
    SIM

    Alexandre Gelin says:
    function separate and aggregation are for different uses and can give the same result, but if you use the aggregate function to get the separate records, it will be expensive...

    really? I find them almost identical to 11g. Actually GROUP BY is almost always more fast for me in the old days.

    article about this askTom Re: any difference between the separate function and aggregation in sql query cost?
    This applies mainly to the older oracle versions http://www.oracle.com/technology/products/rdb/pdf/distinct_derivedtables_groupby_sort_tech_article.pdf

  • The difference between the two copies and Clone?

    I make a copy of an existing symbol. On the Edit menu, they have Dulicate and Clone to achieve this. What is the difference between the two? As far as I can tell, if I select the clone, it puts a copy of the object directly on top of the selected object to copy. If I select duplicate it offered the copy is not directly above the original to copy object. What is the difference?

    Well Yes

    Jim Babbage

  • Not sure of the difference between the two registry paths.

    HKEY_LOCAL_MACHINE tools\msconfig\startupreg\

    entries are stored here, program under key and others, how are they different from the entries stored here...
    HKEY_LOCAL_MACHINE tools\startupreg\
    They two have something to do with starting. someone with a little know-how in this field could be a great help.
    What is the difference between these two and what not the keys of each way folder. ?

    If it is any help, I checked my xp, vista, and win7 and they all have this branch of the registry but it is empty of all keys. for example empty:

    HKEY_LOCAL_MACHINE tools\msconfig\startupreg\

    and none of the bones had the other key that you mentioned. I do not use quicktime, so this may be the reason why.

    If I had to guess with analysis and fiddling with the registry since it was invented by microsoft, registry branch I have is 'standard '.

    While the secondary registry branch that I don't have is "non-standard" and probably created by quicktime or other software during installation.

    These registry branches are created because the manufacturers software third differring depend on utilities such as quicktime will be writtened to find the key in the registration or another branch.  If the additional branch and keys are added for extra measure by quicktime or other programs.

    I think that in your particular case, only quicktime can tell you why they need to put their keys in 2 different branches.  but its likely that my logic above explain the reason for being.

    HTH.

  • What is the difference between the two forums?

    Hi, I am a newbie to the forum and I was wondering what is the difference between the "Razr of Motorola Droid community" and the "community Motorla Razr" I see the links to the right side of the forum support page owners?

    This means that any time you see "Droid" is on the Verizon network in the United States. The software on the Droid Razr is different from what is on the Motorola Razr, so it has a different community so that it can be better supported. I hope this helps.

  • Calculation and display of difference between the two amounts

    Hi all

    I have the report in which I am posting two SUM fields at levels of summaries.

    <? xdoxslt:sum (LINE_QTY)? >
    and
    <? xdoxslt:sum (INV_DIST_AMT)? >

    I want to display another field bordering these fields that will be the difference between these two.

    Can you please tell me the function to achieve.

    Thank you
    Anish.

    Have you tried this:

    If you want to continue using the scope function, then use

  • FormCalc - how to calculate the difference between the two fields datetime in hh: mm?

    Hello!

    I am building a form of time sheet in which I need to calculate the difference between the start and end times and present the result.

    I'm trying to do with FormCalc but if it is easier with JS is ok too.

    So that's what I did on the total field, by using the calculate on a NUMERIC field called decimalValue event:

    elapsed = Time2Num (endTime.formattedValue, "HH: mm")-Time2Num (startTime.formattedValue, "HH: mm")

    And then I tried to convert a time field:

    Total = decimalValue.rawValue;

    $.formattedValue = Num2Time (total, "HH: mm")

    Well, it doesn't work, it gives me crazy results in the datetime (total) field. If I type 09:00 and 09:30, the final result is... 22:30. Huh?

    Please, could someone help me understand how this thing works?

    Thanks a lot for the tips!

    Marcos

    Hi Marcos,

    Here are some examples:

    https://Acrobat.com/#d=kCPIgVkd09qrx6h-WRXxbQ

    https://Acrobat.com/#d=EsWqBMBt3sgEXnMSsK5pRA

    Hope that helps,

    Niall

  • Difference between the two lines in percentage

    Hi all

    I have a requirement to report which should be grouped by months and in the second field all the records for this month, but I have to add a third field that shows the difference of the TOTAL REGISTRANTS BETWEEN above and below months and also the percentage to increase or decrease the number of records between the months... In fact, I am unable to think even of any solution. There is the report look at an end parameters to select the month for which the report should be displayed.

    The report is a bit like that and is grouped by month:

    Month | Total records | Percentage and difference
    January | 10.
    February | 20. 100% 10
    March | 30. 50% 10
    ....
    ...

    But I can't find a way to incorporate data for column 'percentage and difference '.

    I appreciate all the suggestions and possible help...
    I can provide any other details if necessary if it is not clear...

    Thanks and regards,
    Solomon

    Declare two variables and store the current and previous lines count value.
    With this, you can calculate the values of the difference and percentage

  • Difference between the two models of the same product?

    Hello

    I am interested in the HP Envy X 2 on the Danish part of the HP Web site, and there are two models of this product.

    However, I have trouble knowing what the difference is, despite their differences in price which is a little less than $100

    Both models can be seen here:

    http://WWW8.HP.com/DK/da/products/laptops/product-detail.html?OID=5349598

    http://WWW8.HP.com/DK/da/products/laptops/product-detail.html?OID=5327631

    I can't seem to find any differences at all... would appreciate some help here.

    I asked a store who got in touch with HP.

    The g000eo comes with NFC where, as the g001eo ot doesn't have NFC.

    This is the only difference of supposidly.

  • I want to know what is the difference between the two packages to choose from for photoshop.

    Pricing plans and creative Cloud membership | Adobe Creative Cloud

    I am looking to buy photoshop and I see two sets with a price. There is a plan of photography that comes with photoshop cc for 119 a year, and then the other package is a purchase unique app for photoshop cc for 239 per year. They are both the same in photoshop?

    Hi domk15243449,

    Yes, you will get the same version of Photoshop on one of the Plans,

    Please see the following link, it should be useful: helps Photoshop | Differences between Photoshop and creative photography programs Cloud

    Kind regards

    Tanuj

  • What is the difference between the two publish to ftp host and export as html in Muse?

    What is the difference between FTP publishing and export as HTML in Muse? When I had some problems with missing assets, I exported as HTML and fixed it, but it didn't update on the layout of the phone or completely on the desk until I published on ftp. Assuming that perhaps export just updates the files on the server? Thank you

    Hi Brian,.

    Site as HTML export will export just your Muse site on your desktop without making any changes to your site online, but when you select Publish to FTP, it publishes the changes you did for your website online.

    Export to HTML format is mainly used when you want to use any external client to load your site on the server.

    Refer to this document to better understand: Adobe Muse Help | Download a Site from Muse Adobe on a third-party hosting service

    Kind regards

    Akshay

  • Pls tell me the difference between the 2 queries which is related with PIVOT

    Hi all

    While I was looking for the use of the PIVOT operator, in one of the sites I've found the following query is requested to run
    SELECT  *
      FROM  (SELECT job,
                    sum(decode(deptno,10,sal)) DEPT10,
                    sum(decode(deptno,20,sal)) DEPT20,
                    sum(decode(deptno,30,sal)) DEPT30,
                    sum(decode(deptno,40,sal)) DEPT40
               FROM scott.emp
           GROUP BY job)
    ORDER BY 1;
    so I ran the following query (IE, without first part ' SELECT * FROM ')
    SELECT job,
                    sum(decode(deptno,10,sal)) DEPT10,
                    sum(decode(deptno,20,sal)) DEPT20,
                    sum(decode(deptno,30,sal)) DEPT30,
                    sum(decode(deptno,40,sal)) DEPT40
               FROM scott.emp
           GROUP BY job
    We see that for the two motions, I get the same output as follows:
    JOB     DEPT10     DEPT20     DEPT30     DEPT40
    ANALYST          6000          
    CLERK     1300     1900     950     
    MANAGER     2450     2975     2850     
    PRESIDENT     5000               
    SALESMAN               5600     
    could you pls tell me what is the exact difference between 2 requests above and in which respective cases, those that should be used?

    Kind regards

    Yamen

    Published by: Francis 22 Sep, 2009 11:07

    Hello

    SELECT  *
      FROM  (SELECT .........................)
    

    I would quote the internal sql as subquery for my reference in this post.
    That is to say.

    Select * from (subquery)

    You'd be using the way above for many reasons, some grounds are
    (1) you want to display only some columns of all the columns in the subquery (less required by anyone)
    for example

    select first_name, last_name, salary from
          (select first_name, last_name, salary, dept_id, manager from ......)
    

    (2) you want to view / use a few lines on all the rows in the subquery (filtering of lines)

    for example

    select * from
        (select first_name, last_name, salary, dept_id, manager from .....)
       where salary > 5000
    

    (3) you want to reach the exit of with another table subquery

    for example

    select * from
        (select first_name, last_name, salary, dept_id, manager from ......) e,
        department d
        where d.dept_id = e.dept_id
    

    (4) you wish to the output to the format/total of subquery as the use of group by or order by

    for example

    select max(salary), dept_id
        from (select first_name, last_name, salary, dept_id, manager from .....)
        group by dept_id
         order by dept_id
    

    Concerning
    Anurag

  • Any difference between the PDF export and PDF presets?

    Is there a difference in the final product if we export to PDF / X - 1a: 2001 or chooses has screened PDFX-1: 2001? They are the same, it seems, but I want to confirm...

    Thank you

    Luca

    No difference.

  • is their any difference between the appearance of firefox 5.0 in vista and xp?

    I see a picture different firfox 5.0 in the site relative to the one im using it.

    It varies a little. If you have never installed Firefox before 5, so Vista and 7 you will probably get the orange Firefox (abbreviated menus) button while in XP you get the classic menu bar. However, it is easy to switch between them.

    If you want the classic menu bar, press the Alt key to display it, then

    Menu view > toolbars > check the Menu bar

    If you would like the orange button in Firefox, then

    Menu view > toolbars > uncheck the Menu bar

    The menu toolbars is also available as a pop-up when you right to the classic menu bar, or an empty area of the bar tabs, or from various places on the other toolbars.

    ---

    Other than that, the user interface pretty much look the same, reversing the effects of weird translucent window in Vista/7.

Maybe you are looking for

  • This parameter sets the maximum length of a line of response or a header field.

    TOPICS - ILS INITIALLY - APPEAR THEN DISAPPEAR - LEAVING A VERY SMALL ICON AT THE END OF THE TITLE AREA (BLUE ARROW) - THIS ICON WHEN HOVERED ON - STATES, 'MAX LENGTH UNKNOWN FIELD' - SO ALL MY SELECTED - ADD GADGETS IN GOOGLE - HAVE EMPTY POSITIONS

  • Update DST with 64 bit

    Hi, I tried several times to update daylight savings fix for 64-bit for my HTC HD2 smartphone. I use Office 2010, W7 and when I download the 64-bit patch it returns an error advising that the 32-bit is already installed, which is not. My smartphone r

  • Graphics ThinkPad Edge e520 problem

    So I got my new computer laptop and for some reason any graphics card is not working properly. Whenever I try to play starcraft2 on support (which even the chp to intel is able to do), it looks like this when you use the radeon: http://img217.imagesh

  • HP Officejet Pro 8500 A909a scanning install computer

    I have a HP officejet pro 8500. It is installed, and I can easily print to it from my laptop. The scanner works I can scan to a USB device and then manually the port to my computer to download on the internet. However, it the device does not have a t

  • Bkackberry appworld disappears after update

    Then I updated my bb appworld to the last 4.0.0.65 and he disappeared. I can no longer access app world. I have reinstalled TWICE and I can not even find app world. any thoughts?