the MINUS in SQL operator
HelloI use operator less to find no corresponding line in the second request.
After watching the reasult of this query, I searched the result in the second query i only saw the data.
worng it's at LEAST the query returns all rows in the first query that are not returned in the second query.
in my case it returns the rows returned by the second query.
(select distinct lower(trim(to_char(sso))),lower(trim(to_char(region))),to_date(expiration_date,'DD-MM-YY') from ca_ourc_view
where rownum <1001
)
minus
(select distinct lower(trim(to_char(sso))),lower(trim(to_char(region))),to_date(expiration_date,'DD-MM-YY') from ourc_members_v1@gesprd
where rownum <1001
)
Thank youREDA
Using rownum it might give a wrong result because of this.
Published by: user13490545 on February 11, 2011 12:24 AM
Tags: Database
Similar Questions
-
Hi experts,
I want to erase my basics here.
I want to know the order of the sql operation.
in fact the problem with me I've read websites and different blog
on the order of operation of sqkl requests, so I'm confused here.
I think that the order of operation iis
-MY assumptuion-
Of
|
where
|
Group
|
having
|
Select
|
order by
---------------------------
My assupmtion is correct?
If so, then if suppose there is clause rownum in my selection criteria, when
It will apply?
on some sites I've seen criteria below
--------------------------------------------
1. FROM/WHERE clause goes first.
2 ROWNUM is assigned and incremented for each line of output FROM/WHERE clause.
3. SELECT is applied.
4 GROUP BY is applied.
5 WHO is applied.
6 ORDER BY is applied.
-------------------------------------
is that correct or my assumption is correct?
Thank you very much in advance... !!
Kind regards
Prashant
Hello
969262 wrote:
Hello
I'm more confused now that everyone has to give a different answer...:)
Blushadow said something that can really help you:
Queries are not always run in a linear fashion
Once you see a step by step ordered arrangement, it is (at best) how things looked from a point of view, and it can be useful to understand some aspects of the work of the database, but not all.
If you must have a single ordered list, so what you posted first is, according to me, the more accurate for the majority of cases:
- Of
- where
- Group
- having
- Select
- order by
This can help you understand logically how to write SQL statements and predict their outcome. For example, think that, when it happens before that GROUP BY allows to remember that you can not use an aggregate function, such as COUNT in a WHERE clause, because the aggregate functions are calculated as part of the process GROUP.
How to write a SQL statement and how the optimizer decides to pay in fact, are two different things. The optimizer do not follow the sequence posted above, or any other sequence of steps. To see how a particular statement is made, given some data in particular, there is no substitute for watching the execution plan.
-
Dblink Oracle to sql server, multiple database on the same server sql under a dblink
Hi, we managed to set up an Oracle dblink to sql server and retrieve data.
The user of sql server have been using via dblink has access to multiple databases on the same sql server
But the question is how in oracle (if possible) prepend you the SQL access to this?
For example:
Sqlserver_prod has the user sqlserver_user which seems to be set up as default database sqlserver_db1
But we have select access to sqlserver_db2
all work well as sqlserver_user
Select * from table_fromdb1
Select * from dbo.table_fromdb1
Select * from sqlserver_db1.dbo.table_fromdb1
as does
Select * from sqlserver_db2.dbo.table_fromdb2
more in Oracle
Oracle_db a dblink sqlserver_prod. World connection sqlserver_user
everything works fine
Select * from 'table_fromdb1"@sqlserver_prod '.
Select * from 'dbo '. "table_fromdb1"@sqlserver_prod
But how to (if possible) access from oracle
sqlserver_db2.dbo.table_fromdb2
without having to create a new sqlserver_db2_user referenced in a new dblink
If oracle for oracle would be
Select * from remote_oracle_schema.table@remote_oracle_db
Hello
You cannot select a table in a different SQL * database server from that to which the gateway instance connects.
As stated in the documentation-Oracle® database gateway
Installation and Configuration Guide
11g Release 2 (11.2) for AIX 5 L Based Systems (64-bit), HP - UX
Itanium, Solaris (SPARC 64-Bit), Linux x 86 operating system,
and Linux x 86-64
In the section.
The example SQL Server multiple databases: Configuration of the modem router
A separate instance of the gateway that is required for each SQL Server database. Each
instance needs its own Gateway system ID (SID).
==========
You will need to create a new instance of the gateway for the SQL * Server DB2 as well as a link separate db.
Kind regards
Mike
-
A question on the impact of SQL * PLUS SERVEROUTPUT Optionconcernant v$ sql
Hello everyone,
I would like to ask a question about SQL * Plus SET SERVEROUTPUT option on / off and its impact on queries on views such as v$ sql and v$ session. This is the problemSQL> SELECT * FROM v$version; BANNER ------------------------------------------------------------------------------ Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production PL/SQL Release 11.2.0.1.0 - Production CORE 11.2.0.1.0 Production TNS for Linux: Version 11.2.0.1.0 - Production NLSRTL Version 11.2.0.1.0 - Production SQL> OS : Fedora Core 17 (X86_64) Kernel 3.6.6-1.fc17.x86_64
In fact I define three variables in SQL * Plus to store sidcolumns, serial # and prev_sql_id of session $ v in order to be used later, several times in various other queries, while I work always in the current session.
So, here's how
Now let's say I want to run the following query as the last SQL statement is executed within my current sessionSET SERVEROUTPUT ON; -- I often activate this option as the first line of almost all of my SQL-PL/SQL script files SET SQLBLANKLINES ON; VARIABLE mysid NUMBER VARIABLE myserial# NUMBER; VARIABLE saved_sql_id VARCHAR2(13); -- So first I store sid and serial# for the current session BEGIN SELECT sid, serial# INTO :mysid, :myserial# FROM v$session WHERE audsid = SYS_CONTEXT('UserEnv', 'SessionId'); END; / PL/SQL procedure successfully completed. -- Just check to see the result SQL> SELECT :mysid, :myserial# FROM DUAL; :MYSID :MYSERIAL# ---------- ---------- 129 1067 SQL>
According to the reference of database Oracle® 11 g Release 2 (11.2) description of session $ vSELECT * FROM employees WHERE salary >= 2800 AND ROWNUM <= 10;
http://docs.Oracle.com/CD/E11882_01/server.112/e25513/dynviews_3016.htm#REFRN30223]
column prev_sql_id includes the sql_id of the last executed sql statement for the sid and serial data which, in the case of my example, it will be the above mentioned query SELECT on the employees table. So right after the SELECT statement on the employees table I have run the following
The value of sql_id, I'm supposed to find all the information on the sliders for my SELECT statement and also its value sql_text in v$ sql. Here is what I get when I query v$ sql on the stored sql_idBEGIN SELECT prev_sql_id INTO :saved_sql_id FROM v$session WHERE sid = :mysid AND serial# = :myserial#; END; / PL/SQL procedure successfully completed. SQL> SELECT :saved_sql_id FROM DUAL; :SAVED_SQL_ID -------------------------------- 9babjv8yq8ru3 SQL>
So instead ofSELECT child_number, sql_id, sql_text FROM v$sql WHERE sql_id = :saved_sql_id; CHILD_NUMBER SQL_ID SQL_TEXT ------------ -------------- ------------------------------- 0 9babjv8yq8ru3 BEGIN DBMS_OUTPUT.GET_LINES(:LINES, :NUMLINES); END;
get the next value for the value of sql_textSELECT * FROM employees WHERE salary >= 2800 AND ROWNUM <= 10;
Which is of course not what I expected to find in v$ sql for the given sql_id.BEGIN DBMS_OUTPUT.GET_LINES(:LINES, :NUMLINES);
After a little googling, I found the next thread on OTN forum, where it was suggested (well, I think that may not be exactly the same problem) to disable SERVEROUTPUT.
Problem with dbms_xplan.display_cursor
It was exactly what I did
After that, I repeated the procedure as a whole and this time everything worked pretty much as expected. I checked SQL * more documentation for SERVEROUTPUTSET SERVEROUTPUT OFF
and also the page of v$ session, yet I don't find nothing indicating that SERVEROUTPUT should be operated off every time that views such as v$ sql, v $session
are queired. I don't really understand the link in what concerns the impact that can have on the other or better say rather, why is there an impact
Could someone kindly do a few details?
Thanks in advance,
Kind regards
Dariyoosh>
and also the page of v$ session, yet I don't find nothing indicating that SERVEROUTPUT should be operated off every time that views such as v$ sql, v $session
are queired. I don't really understand the link in what concerns the impact that can have on the other or better say rather, why is there an impactHi Dariyoosh,
SET SERVEROUTPUT ON has the effect of dbms_output.get_lines running after each statement. Not only related to the system view.Below is what Tom Kyte is explained in this page:
Now, sqlplus sees this feature and says "Hey, it wouldn't be nice for me to empty the buffer to the screen for the user? Thus, they added the command SQLPlus "set serveroutput we" which does two things
(1) he tells SQLPLUS you would like run dbms_output.get_lines after each statement. You would like to make this network rounded up after each call. You want that this additional load will take place (think of a script of installation with hundreds / thousands of statements to run - maybe, just maybe you don't want this extra call after each call)
(2) SQLPLUS automatically calls the API dbms_output "activate" to activate the buffering which is in the package.
Kind regards.
Al -
If / then the Concepts using SQL not PL/SQL - avoid ORA-00942
Hello
Im trying to write a monitor which works in all of 80 db (where there is only applicable 7 db)-I want it simply returns the null value or no line on the DB is not required on as it is integrated into a model
A simplified version of the query "select col1, col2 from cat1.helptab.
It's very good for all the DB who actually have cat1.helpteb in their breast, but for those who are not obviously ORA-00942: table or view does not exist is returned.
I need to write a SQL statement that can move, * due to specific requirements, I can't use the PL/SQL for this *.
Any ideas how I can construct the statement above return null or 'no reurned lines' if cat1.helptab does not exist in the comic book?... instead of return ORA-00942
Any help would be appreciatedWhat is the interms impact of objects are created in the DB? nothing?
All operators/functions are generally available out of the box in a standard enterprise db installation.
Your admin could gave a restricted access to (or uninstalled) dbms_xmlgen well - one thing I would check beforehand.How this same method would work for the selection of a column that does not exist?
Almost the same:
SQL> select extract (x.column_value, 'ROW/DEPTNO/text()').getnumberval () deptno, extract (x.column_value, 'ROW/DNAME/text()').getstringval () dname, extract (x.column_value, 'ROW/ALERT/text()').getstringval () alert from all_tables, table ( xmlsequence ( dbms_xmlgen.getxmltype ('select deptno, dname, ''WARNING'' alert from ' || owner || '.' || table_name || ' where deptno > 30').extract ( 'ROWSET/ROW'))) x where owner = 'MICHAEL' and table_name = 'DEPT' / DEPTNO DNAME ALERT ---------- ------------------------------ ------------------------------ 40 OPERATIONS WARNING 50 SALES WARNING 2 rows selected.
-
Can I use PXI embedded controller connected to the PC under LINUX operating system
Hi all
We ara tries to connect to PXI8106 (in 1042 chassis) to PC under LINUX via ethernet (cable cross at the moment), is the version of labview 8.5.
Can I use PXI embedded controller connected to the PC under LINUX operating system?
If Yes, where can I find its configuration in the .ini file?
Thanks in advance.
Hello bachir_elec,
I'm sending you two links that I don't provide the information you need.
Using Linux on an Embedeed PXI controller:
http://digital.NI.com/public.nsf/allkb/821E0C115A3B4EF286257069004B8352?OpenDocument
Configuration of your PXI Linux system:
http://digital.NI.com/public.nsf/allkb/5CEEC941FB7B0488862573F700653B21?OpenDocument
You can take a look?
-
How to skip the installation of SQL Express 2005 and using SQL Express 2008 instead?
I have SQL Express 2008 is installed and you want to use instead of SQL Express 2005.
How to configure the installation of Lookout as he ignores the installation of SQL Express 2005?
Are there other measures that must be taken so that Lookout can work properly with SQL Express 2008?
Thank you.
OK - it worked.
However, for 64-bit installations, I had to use the WOW of SQL Express 2008 versions, because, the Citadel is a 32-bit database and installation of 64-bit native versions would not allow an upgrade of the Citadel of Instance.
Thank you.
-
Error message when I run delete the query in SQL Server 2008.
Error message when I run delete the query in SQL Server 2008 SP3.
Error message:
MSG 0, level 11, State 0, line 0
A serious error occurred on the current command. The results, if any, should be discarded.I never got any problem since 5 years.
Please let me know what is the cause of the problem.
You can get a response better/faster if repost you your question in the instances of SQL Server dedicated from Microsoft here:
http://social.technet.microsoft.com/Forums/en-us/category/sqlserver .
Thank you. :)
(I'm sorry, but I can't move this thread for you because the two forums are working on separate platforms)
-
Do not install the update for SQL Server 2005 Service Pack 3 (KB970892) security code error C0000005
This update didn't install when I used Vista and is still unable to install now, I updated to Windows 7.
Have searched for a solution for months with no result. Reason why I updated.
Any help much appreciated.
DOUGY,
Microsoft SQL Server 2005 Express Edition Service Pack
Post here for assistance:
http://social.msdn.Microsoft.com/forums/en-us/sqlsetupandupgrade/threads/
--
-
With the help of an operating system older Compaq is professional Windows. Internet Explorer connected very slowly. SO I've reworded in safe mode with network and IE has worked very well. I installed Mozilla Firefox and then restarted in normal mode. Then Internet explorer would not connect. How to diagnose in safe mode. What does safe mode or safe mode with network do to help diagnose? Can someone help me solve this problem? Any help would be appreciated thanks in advance.
Hi, Raymond J,.
· Did you do changes on the computer before the show?
· You get the error message?
· What type of internet connection do you use?
· What security software do you use?
Follow these methods.
Method 1: As the problem does not persist in SafeMode with network, perform a clean boot to see if there is a software conflict as the clean boot helps eliminate software conflicts.
Note: After completing the steps in the clean boot troubleshooting, follow the section How to configure Windows to use a Normal startup state of the link to return the computer to a Normal startupmode.
After the clean boot used to resolve the problem, you can follow these steps to configure Windows XP to start normally.
(a) click Start, run.
(b) type msconfigand click OK.
(c) the System Configuration Utility dialog box appears.
(d) click the general tab, click Normal startup - load all services and device drivers and then click OK.
(e) when you are prompted, click restart to restart the computer.
Method 2: Follow the steps in the article.
How to troubleshoot possible causes of Internet connection problems in Windows XP
-
Original title: 0x000000f4 beginning physical memory dump
STOP: 0x000000f4 (0 x 00000003, 0x89cb3a18, 0x89cb3b8c, 0x805d29b4) beginning physical memory dump
This is the error message I got when I perform the adaptation of data operation or run heavy programs, and when I play the music of his tempo becomes slower... What do I do? Help, please...Hello
You did changes to the computer before this problem?
Step 1: Check if the problem persists in the clean boot state.
From your computer by using a minimal set of drivers and startup programs so that you can determine if a background program is interfering with your game or program. This type of boot is known as a "clean boot".
Reference:
How to configure Windows XP to start in a "clean boot" State
http://support.Microsoft.com/kb/310353When you are finished troubleshooting, follow these steps to reset the computer to start as usual:
1. click on start and then click Run.
2. type msconfig and click OK.The System Configuration Utility dialog box appears.
3. click on the tab general, click Normal Startup - load all services and device drivers and then click OK.
4. When prompted, click on restart to restart the computer.Step 2: Also, look for error messages in the event viewer. If you find error messages after return the exact error message so that we can help you better.
Reference:
Using the event viewer
http://www.Microsoft.com/resources/documentation/Windows/XP/all/proddocs/en-us/snap_event_viewer.mspx?mfr=trueUnderstanding of event viewer
http://www.Microsoft.com/resources/documentation/Windows/XP/all/proddocs/en-us/event_overview_01.mspx?mfr=trueProcedure to view and manage event logs in Event Viewer in Windows XP
http://support.Microsoft.com/kb/308427 -
original title: SQL Server 2008
We have SQL Server 2005 cluster (3 node cluster) and if we improve this nodes to 2008 R2, can the databases associated with the named instance remain to the version of SQL Server 2005, I seem to disagree with this notion, but still need to validation of the pro.
One way I can think of to achieve this scenario changes the compatibility level to SQL Server 2005 when the node has been upgraded to SQL Server 2008, so we can upgrade databases to SQL 2008 as and when the vendors provide support for this version.
Hello
Here is the Vista forums
Try the links below:
SQL Server forums
http://social.technet.Microsoft.com/forums/en-us/category/SQLServer/
SQL Server TechCenter
http://TechNet.Microsoft.com/en-us/SQLServer/bb265254.aspx
Blogs and Forums SQL server 2008
http://www.Microsoft.com/sqlserver/2008/en/us/forums-blogs.aspx
-
How can I access a journal or a report that lists the results of an operation of Disk Defragmenter?
Windows Defrag is supposed to run silently in the background.
Unlike XP, it does not offer a newspaper to the user, as far as I understand.If you schedule a defrag, you can let it run in the background and forget it.
Schedule defragmentationStart button > Search box, type Task Scheduler > pressenter > invite uac, click on continue or enter the admin password >
(click on the pointer before) to expand Task Scheduler Library >
expnad Microsoft >
Expand Windows >
Click on Defrag > the middle column, click scheduled d.... >
right column, click Properties > click triggers tab at the top > click on Edit > select / adjust how to defragment Appendix to be executed, select options >
at the bottom of the box, place a check on " enable " >
OK > OK yet > exit the Task Scheduler window. -
I have a laptop broke the rocovery disk not good ahy, I need the windows vista disk operating system how do I get the same themes?
If Windows Vista was preinstalled on your computer, contact the manufacturer of your computer for a replacement CD. If you purchased a retail version of Windows Vista, contact Microsoft.
This article in the Microsoft Knowledge Base has the details: How to replace Microsoft software or hardware, order service packs and updates of product and replace product manuals . Boulder computer Maven
Most Microsoft Valuable Professional -
What is the printer that HP 7525 works with the windows 8.1 operating system?
What is the printer HP 7525 Photo Smart works with the windows 8.1 operating system?
Hi Alex7171,
Yes it does, you can follow this link to download drivers
http://h10025.www1.HP.com/ewfrf/wc/softwareCategory?cc=us&DLC=en&LC=en&product=5286643&I
Maybe you are looking for
-
Notifications to require tap to display?
Just upgraded to watch OS 3 and noticed that notifications now require a tap to view details. For example, if I get an iMessage, iMessage icon is displayed on the watch, but I have to tap it to read the message. Similarly, if I get an alert for an up
-
Do I need steam to play shogun 2 when I bought in Mac AppStore
Hi, I want to buy shogun 2 from the Mac App Store, but I didn't know if you need steam to play, when you bought in the mac app store. Best regards, Thijmen
-
HP Officejet 8610: Cut 2 sided copy printer interface
I need help turning off two-sided copy using the inetrface on the printer. I have no problesm but cpying printer problems. If I print two pages in two original copies, the printer wants to enter the page firstcopied and pull of iut in the printer to
-
Data Plug In required format EV5 NHTSA crash test data
I was hoping that someone could make or link me to a Plug In data for this data type: The link to the site is here:http://www-nrd.nhtsa.dot.gov/database/aspx/vehdb/testtabledetails.aspx?LJC=7481&existphoto=Y&p_tstno... Thank you very much
-
data transmission between the General case and problems of timing instructions using daq devices
I'm currently developing a program using LabView 2012 SP1. I am interfacing with an NI USB-6009 data acquisition using NOR-DAQmx 9.5.5f4. I'm trying to get a voltage on the three analog inputs (AI0 and AI3 AI4) 1 second to start and 20 seconds of s