Comparing the 2 sets of results
HelloI compare the 2 sets of results and determine if they are identical.
Queries are:
SELECT CARRIER_ID, ROUTE_POSITION
OF ROUTE_WG_PHASE4
SELECT CARRIER_ID, ROUTE_POSITION
OF ROUTE_WG_PHASE3
I tried to use less, but it does not work when the first result set has fewer than the second record.
Oracle 10g
Thank you
In general, you can do something like
(
SELECT CARRIER_ID,ROUTE_POSITION , 'In 4 and not 3' desc
FROM ROUTE_WG_PHASE4
MINUS
SELECT CARRIER_ID,ROUTE_POSITION , 'In 4 and not 3' desc
FROM ROUTE_WG_PHASE3
)
UNION ALL
(
SELECT CARRIER_ID,ROUTE_POSITION , 'In 3 and not 4' desc
FROM ROUTE_WG_PHASE3
MINUS
SELECT CARRIER_ID,ROUTE_POSITION , 'In 3 and not 4' desc
FROM ROUTE_WG_PHASE4
)
According to the specificity of your data, you can also just add a COUNT (*) () to each query and a single NEGATIVE sign.
Justin
Tags: Database
Similar Questions
-
Query to get the data of the column and the metadata in the same set of results.
Is it possible to build a query to get the values of the columns in a table and also be able to get some metadata (data type, data_length, data_precision, data_scale) for columns in the same set of results.If I use a join, have a common value to join on the two tables?
you use a cross join, not requiring common values.
create table T (n number, d date, v varchar2(30)); insert into T values (1,sysdate,'ABC'); commit; select C.column_name, c.data_type, c.data_length, case c.column_id when 1 then to_char(T.N) when 2 then to_char(T.D) when 3 then T.V end VALUE from USER_TAB_COLUMNS C, T where C.table_name='T' order by c.column_id;
-
Total amount and are rotating back in the same set of results
I want to return a set of results in the following format:
where the total amount is the sum of the hours for all types of models grouped by yearmonth and columns of each model are the sum of hours per type of model grouped by yearmonth. I can get the correct results with the following query selects nested:YEARMONTH Total ModelA ModelB ModelC 200101 0 0 0 0 200102 10 5 5 0 200103 8 2 2 4
I was curious to try use the pivot function in Oracle 11 to get the same results and I am able to get all the results, EXCEPT the total number of hours by using the following query:select distinct yearmonth, sum(a.hours) as Total, (select sum(b.hours) from model_hours b where model = 'ModelA' and a.yearmonth = b.yearmonth) as ModelA, (select sum(b.hours) from model_hours b where model = 'ModelB' and a.yearmonth = b.yearmonth) as ModelB, (select sum(b.hours) from model_hours b where model = 'ModelC' and a.yearmonth = b.yearmonth) as ModelC from model_hours a group by yearmonth order by yearmonth
which returns this result:select * from ( select yearmonth, hours, model from model_hours a ) pivot ( sum(hours) for model in ('ModelA', 'ModelB', 'ModelC') ) order by yearmonth
I was not able to understand how to get the sum of hours for all models, grouped by yearmonth, in this result set also. Is this possible? And if yes, isn't - that's likely to be more effective than selects it nested? This particular table has some 200K lines right now.YEARMONTH ModelA ModelB ModelC 200101 0 0 0 200102 5 5 0 200103 2 2 4
Hello
As far as I know, the Oracle 11 SELECT... PIVOT function only works on mutually exclusive groups.
You can derive the total revolving data, like this:WITH pivoted_data AS ( select * from ( select yearmonth, hours, model from model_hours a ) pivot ( sum(hours) for model in ( 'ModelA' AS modela , 'ModelB' AS modelb , 'ModelC' AS modelc ) ) ) SELECT yearmonth , modela + modelb + modelc AS totla -- may need chnaging if values can be NULL , modela, modelb, modec FROM pivoted_data ORDER BY yearmonth ;
Published by: Frank Kulash, 26 March 2012 15:01
-
By comparing the value 'sets '.
Hello
I have a table TAB1 resembling:
I would compare the values separated by commas of DESCRIPTION field with values separated by commas of a user input string. It would be something like:COL DESCRIPTION ---- ----------- 1001 10,11,12 1002 10,11 1003 10 1004
If the user enters anything, the result of the query would be 1001, 1002, 1003, 1004SELECT COL FROM TAB1 WHERE <user_input> IN DESCRIPTION
If the user enters "10" the result of the query would be 1001, 1002, 1003
If the user enters the "11" the result of the query would be 1001, 1002
If the user enters 10 ', 12' the result of the query would be 1001
How can I apply this in Oracle 10 g?
PS: The comma separate values in the DESCRIPTION field and user input are always sorted/ordered!
Thanks in advance,
Peter
Published by: user3764335 on June 7, 2011 02:53You can try something like
Where ','||description||',' like '%,'||replace(user_input,',',',%,')||',%'
NOT TESTED
Max
-
Comparing the data set of Oracle database local to the Remote SQL Server database
Hello
I have a table in an Oracle database that is gradually being updated with a table in SQL server through the database link. There is a field "Date of creation" in the table in SQL server that I used to find the newly created records and shoot and insert them into the local table to the Oracle database.
Now the question is the documents/data in the SQL server remote can be deleted as well and I see a lot of files are already deleted and I couldn't find a way to capture the information of deleted data to remove from my local table.
I tried
SELECT id local_table
where there is no
(select * (or 1))
of remote_table@database_link
where remote_table.id = local_table.id).
And I tried to replace not exist with no so.
The problem is that the query is too slow with link of database for IN/NOT EXISTS clause NO. So, I'm trying to find an effective way to capture the lines deleted in the remote to remove as a result of my local table table.
Any help is appreciated.
Oracle Database 11 g Enterprise Edition Release 11.2.0.2.0 - 64 bit
Thank you
Chrystelle
It is perhaps easier
Select pk / * or sustitutive key * / from Oracle.tba
less
Select pk / * or sustitutive key * / from SQLSERVER.tab
This returns the rows that exist in Oracle but not in SQL SERVER-> delteted lines in SQL Server.
Another way is to create a trigger to remove in sqlserver and track in a table delete lines.
HTH - Antonio NAVARRO
-
Compare the 2 sets of tuninng sql
Is it possible to compare 2 SQL Tunning games?
I want to compare SQL response times to different sql tunning games.
Is this possible?
Thank you to
Try this: comparing SQL tests
Onkar
-
How to compare the time slices in 15 minutes?
Using Flash 8 Pro AS2
Have an animation to play once at the first visit to the site, regardless of the number of pages visited within the site. Then start over when to return to site.
I thought that SharedObject would work for this. I managed to do it run at the same time to visit the site and the value of the shared object. Problem is that the animation NEVER play again because the shared object is never removed.
Is there a way to put so it was like a session then that would solve this easy. I don't know how to do if there is a way.
So I decided to make the swf file to check the page reload or if come back once again, site 15 minutes has elapsed. If so, update the time in being shared right now and the animation playback.
Problem is that I have NO idea how compare the time set in the shared object at the moment to check whether or not the 15 minutes has passed.
I tried different things, but the comparison, at the end of the hour, goes into the negative numbers. I am here minutes passing between saved time and the current time. Nothing else for a few minutes.
I'm not a mathematical genius or understand all the stuff that I see out there in the tutorials and code examples, when it comes to the date and the time of calculation.
I need to be. Delete the shared object to the closure or the site navigation browser.
OR
Check if 15 minutes has passed then at day time in the shared object and read the animation
I'm just stuck in the calculation of time to determine whether or not the 15 minutes passed.
What happens if they return to the site of the days or even weeks? My minutes of follow-up test has no meaning when entering hours and days or even weeks or months. Of course, my approach does NOT work.
Any help would be great. Don't forget to Flash 8 pro and AS2 NOT AS3 or flash 9.
Thank youI don't know how you look at the time, but if you create a DATE object:
var today: Date = new Date(); It's actually an object of date and time.
So, if you compare this date and time with an earlier date object and the object of time by using the Date method getTime() as follows
Now.getTime () - previousDate.getTime () = the number of milliseconds that have elapsed between the "previousDate' and 'now '. If the difference is > 15 * 60 * 1000, 15 minutes.
-
When I subtract two numbers DBL and try to compare the result with another DBL, it fails
I found a curious problem with subtraction and compare numbers DBL in LabVIEW (8.6). Here's how it works:
1. subtract two numbers DBL such that the result is not incorporated. (Say, 3.2 - 3.1)
2. compare the result with a constant/control that is on the result of the subtraction (in the example, 0.1)
3 see the output of the comparison.
If the result of the subtraction is an integer, the Boolean result is (as expected). If the result is not complete, the comparison fails.
(Now, if I simply compare two floating point numbers, it works, so the issue is not with the node comparison itself, but with the data that is entered to the node). Can someone understand why this happens? It's unexpected, it's a pretty serious bug.
It is provided with all programming languages. Numbers do not have an exact binary floating-point representation. This has been discussed endlessly. Never use the equal function with floats. You can use the function in the range and force.
-
I get error frequently below. In General, when you navigate on old posts on the forum SQL and PL/SQL, after reading a post, I click on the left arrow in my Firefox browser, which I expect to take me to the page of the posts that I had. Instead, I get a page with no messages. I then click on a forum page numbers in the upper right corner. Sometimes brings back me to the page that displays the list of the posts that I had. However, more often I get the below error. So try to navigate from one position to another is desperately slow. You can fix this? Everybody brings a work around to be able to get from one station to another, or at least back to old messages without the error page? This is a problem that happened before and after the upgrade.
"You have reached the maximum of pages in this set of results of content. If you are looking for something specific, try applying a filter of content type or enter a search term. »
Have you tried right-click (ctrl-click on Mac) and choose 'Open link in a new tab' instead? With all the dynamic html today browser back and before options are often dead still. If you open links in a new tab or window, you can simply close the window instead of using the back button. It may take awhile to get used to it, but there are some benefits, such as the loading of the pages in the background, and you do not lose the focus of the page where you. You can disable "when I open a link in a new tab, swtich it immediately." If I understand your problem, maybe it works better.
-
Change the default setting selected on the ground of 'Culminating point search results' in research
Anyone know any changes "under the hood" that can be done to make the "highlight search results" field in the search value unchecked and unverified? I see in the recipe SSL where for him to appear or not appear (and change the color of the highlight), but nothing about what makes the unchecked in WebHelp result value (or other forms of the help output where it may appear).
I have it! -Yes, it's in this file whform.js - it's this section (hope of line 228 - it is OK):
If (gbHighlightSearch == true) {}
"sForm +=".
"+ gsHiliteSearchTitle +" ";}
If you remove the "checked" on this line bit, it sets the State of the 'unchecked' box in the search pane.
-
Compare the result of a query with a number and return a message
Hello
I have the following query in oracle 9i:
SELECT COUNT (*)
OF hourly_files
WHERE date_received = TO_DATE ((SELECT TO_CHAR (SYSDATE - INTERVAL '1' DAY, 'DDMMYYYY')
(THE DOUBLE), 'DDMMYYYY');
This will produce a number of lines required
I need to compare the number of output with another number hardcoded (threshold) and print an appropriate example message
If the result of the query above is 18000 and the number of threshold is fixed at 20000, then output a meesage:
Number of files received less than 2000
Any help will be very appreciated!
Thank you.SQL> ed Wrote file afiedt.buf 1 SELECT CASE WHEN COUNT(*) >5 THEN 'Number is > than 5' 2 WHEN COUNT(*) <1 THEN 'Its less than 1' 3 ELSE 'Its in between' 4 END 5 FROM emp 6* WHERE deptno=20 SQL> / CASEWHENCOUNT(*)>5 ------------------ Its in between SQL> SELECT COUNT(*) FROM emp 2 WHERE deptno=10; COUNT(*) ---------- 3
-
iDoc Script to compare the metadata
Scenario:
Customers has a workflow approvers reviewers are selected when check-in, metadata and metadata xRevisors, xApprovers, is the list of multiple options and a table users view. But, the author, reviewer, and approver cannot be the same person. I create an iDoc Script to check for this, in the first step of the workflow:
< $if author as "xRevisors" or dDocAuthor as 'xApprovers' or xRevisors like $ "xApprovers" >
< $wfSet ("wfJumpName", "Check_participantes") $>
< $wfSet ("wfJumpTargetStep", "contribution@HmbGgqDocQualidade") $>
< $wfSet ("wfJumpEntryNotifyOff", "0") $>
< $wfSet ("wfJumpMessage", "author, reviewer, and approver cannot be the same person.") ") $>
< $endif$ >
This work when I choose as a reviewer or an approver, but stand them sometimes more than one person and that's my problem, xRevisors and xApprovers metadata save more than one user, then author as reviewer or approver compare it is false. How to make the script check this?
Or just convert the strings separated by commas results (<$rsMakeFromString$>) and loop games result sets. This should be fairly simple.
On another note, I see even where this line of code would work.
<$if author="" like="" "xrevisors"="" or="" ddocauthor="" like="" "xapprovers"="" or="" xrevisors="" like="" "xapprovers"$="">-It's not comparing the fields, he compares a literal string, namely "is the value of the author as the word"xRevisors "? How does this even in the first place?
$if>$rsMakeFromString$>
-
By comparing the child entity instances
I have 3 entities (including global) say (global) Contact, case, product. There are 1:m relationship between Contact-> cases and case product. Say there are two cases of case (Case1 and CAS2) and each instance case has 3 instances of product (cases1: Product1, Product2, Product3;) Case2: Product4, HCnda5, product6). Now, I need to compare if any product is different from the cases1, CAS2 and in case any other product is then I need to update a field with "New Elements" (for example). I went through all the functions available in OPM, but could not find something suitable for this requirement. Please suggest.
Thanks in advance.
2738155 wrote:
debugger is unable to identify that this case must be treated case of update and therefore not give output 'uncertain '. But once the case is selected manually, everything works fine. Please suggest.
Which is expected. The two instances of cases will be treated identically until you describe which is the former stop and which is the new case. There are two ways to do this.
1. manually to identify new cases and the elders by assigning a case as the target of another case of 'update of the case' relationship
2. deduce the new case and the former by making her relationship 'update of the case"a deducted (you will need to change to one-to-many) and then writes a rule to assign a case as the target of another case of 'update of the case".
The first option is fairly simple, the second option will result in a "is a member of the rule.
the case (new) is a member of the update of the case if
the new case is not the case; and
The conclusion set out in the above rule is a statement IsMemberOf who deduct membership "updated of the case", using an alias to distinguish between "affair" (source) and "new case" (possible target).
The first premise "the new deal is not the case" makes them a case cannot be its own update.
After that, you need to add the rules that distinguish the case of update of the former judgment.
The complexity with trying to reason on two instances of the same entity is why I suggested originally to use difference for the old and the new housing entities.
-
How to compare the length of the data to a staging table with the definition of the base table
Hello
I have two tables: staging of the table and the base table.
I get flatfiles data in the staging of the table, depending on the structure of the requirement of staging of the table and the base table (length of each column in the staging table is 25% more data dump without errors) are different for ex: If we have the city long varchar 40 column in table staging there 25 in the base table. Once data are discharged into the intermediate table that I want to compare the actual length of the data for each column in the staging table with the database table definition (data_length for each column of all_tab_columns) and if no column is different length that I need to update the corresponding line in the intermediate table which also has an indicator called err_length.
so for that I use the cursor c1 is select length (a.id), length (b.SID) of staging_table;
c2 (name varchar2) cursor is select data_length all_tab_columns where table_name = 'BASE_TABLE' and column_name = name;
But we get atonce data in the first query while the second slider, I need to get for each column and then compare with the first?
Can someone tell me how to get the desired results?
Thank you
Manoi.Hey, Marco.
Of course, you can set src.err_length in the USING clause (where you can reference all_tab_columns) and use this value in the SET clause.
It is:MERGE INTO staging_table dst USING ( WITH got_lengths AS ( SELECT MAX (CASE WHEN column_name = 'ENAME' THEN data_length END) AS ename_len , MAX (CASE WHEN column_name = 'JOB' THEN data_length END) AS job_len FROM all_tab_columns WHERE owner = 'SCOTT' AND table_name = 'EMP' ) SELECT s.ename , s.job , CASE WHEN LENGTH (s.ename) > l.ename_len THEN 'ENAME ' END || CASE WHEN LENGTH (s.job) > l.job_len THEN 'JOB ' END AS err_length FROM staging_table s JOIN got_lengths l ON LENGTH (s.ename) > l.ename_len OR LENGTH (s.job) > l.job_len ) src ON (src.ename = dst.ename) WHEN MATCHED THEN UPDATE SET dst.err_length = src.err_length ;
As you can see, you have to hardcode the names of the columns common to several places. I swam () to simplify that, but I found an interesting (at least for me) alternative grouping function involving the STRAGG user_defined.
As you can see, only the subquery USING is changed.MERGE INTO staging_table dst USING ( SELECT s.ename , s.job , STRAGG (l.column_name) AS err_length FROM staging_table s JOIN all_tab_columns l ON l.data_length < LENGTH ( CASE l.column_name WHEN 'ENAME' THEN ename WHEN 'JOB' THEN job END ) WHERE l.owner = 'SCOTT' AND l.table_name = 'EMP' AND l.data_type = 'VARCHAR2' GROUP BY s.ename , s.job ) src ON (src.ename = dst.ename) WHEN MATCHED THEN UPDATE SET dst.err_length = src.err_length ;
Instead of the user-defined STRAGG (that you can copy from AskTom), you can also use the undocumented, or from Oracle 11.2, WM_CONCAT LISTAGG built-in function.
-
Compare the same value of the column
Hello
I have table as below
Now, I need to compare the date of each Department and return the case to higher-value Date only in this Department. my result set must therefore as below:ID Date Department 1 25-Jul-08 XX 2 26-Jul-08 XX 3 22-May-08 YY 4 23-May-08 YY 5 24-May-08 YY 6 13-Jun-08 ZZ 7 14-Jun-08 ZZ
any idea?ID Date Department 2 26-Jul-08 XX 5 24-May-08 YY 7 14-Jun-08 ZZ
Is only one record in the Department with the highest date?
If so, use aggregate KEEP statement:SELECT max (id) to Dungeon code (dense_rank of first order of date # desc).
Max(date#), Department of
OfGroup of Department;
If several whan a line with the date of the highest can exist in a single Department, use
SELECT id, date #, Department
de)
SELECT id, date #, Department, dense_rank() on Dr. (depatyment date order partition # desc)
Of
)
where dr = 1(Not tested!)
Rgds.
Maybe you are looking for
-
Equium L100 186 - cannot start the cd
Hello, I got a older laptop: p I erase my hd and now I'm putting windows xp again, but when I try to boot the CD, the display shows "Operating system not found" could anyone kno how I can solve it? Thank you!! :)
-
Erased dvd movie that I bought at Walmart
I bought a movie DVD (Madeas Christmas) at Wal-Mart, a couple of days. Brought it home. Watch the entire film. When I tried to watch with the family again, my DVD player kept asking to load a DVD. He was already in the player. It's good that it has
-
I have recently upgraded to Windows 8. 1. Since then, I can't scan multiple pages in PDF format. Also does not have the familiar scanning application. New application does not allow me to scan in PDF or scan multiple pages. I tried to reinstall fr
-
How can I fix windows 7 Catalyst control center host application has stopped working
I received the error: Catalyst Control Centre: host application has stopped working. I uninstalled the Device Manager Catalyst Control Center and restarted - after uninstall and reboot I got the same message saying: Catalyst Control Center: the host
-
Neue cam win 7 is und kompatible wird zwar alles gut aber nicht of started I said
Hallo habe eine cam so wird auch das alles hat everything I said also mit der und alles ist aber trotzdem geht nicht cam one die scripte instalation was ist das thanks