two table Merge
TABLE-A
SELECT * FROM A
---------------------------
ID
--------------------------
1
2
TABLE-B
SELECT * FROM A
---------------------------
NAME
----------------------------
MARY
JOHN
I want to SELECT results
ID NAME
---------------------------
MARY
JOHN
1 MARY
1 JOHN
MARIE 2
2 JOHN
-----------------------------------
How do I?
Try the below
SELECT CAST (NULL AS NUMBER (10)), the name OF tableB
UNION ALL
SELECT id, name FROM tableA, tableB.
Post edited by: 000000
Tags: Database
Similar Questions
-
Hello
I have a question about the merger of the two 2D arrays. I have a program that generates two tables different interms of binary digits (attached file) and I wanted to arrange them as below.
The first generation of table: 1110
1101
1011
0111
Second generated table: 0001
0010
0100
1000
Output should be: 1110
0001
1101
0010
1011
0100
0111
1000
Thank you.
Hello
Order the attached VI
Kind regards
Amine31
(Give congratulations to good answers and Mark as a Solution If your problem is resolved)
-
I have two tables I have merged into a single view.
All rows from both tables to merge into a single view.
Not table 1 no criteria:
Table 2 criteria:MATERIAL PLANT QUANTITY UNIT POSTING_DATE
The view should look like this:MATERIAL PLANT SALES_QUANTITY UNIT POSTING_DATE RECORD_TYPE Where RECORD_TYPE IN('O','U')
I'm not going anywhere, what should I do?MATERIAL PLANT QUANTITY UNIT POSTING_DATE
Hello
Maybe you want something like this:
CREATE OR REPLACE VIEW table_1_and_ou_from_2 AS -- SELECT material, plant, quantity, unit, posting_date FROM table1 -- UNION ALL -- SELECT material, plant, sales_quantity, unit, posting_date FROM table2 WHERE record_type IN ('O', 'U') ;
The columns in the view will have the same names that the columns of the 1st branch of the UNION, then the 3rd column will be called quantity, not sales_quantity.
I hope that answers your question.
Otherwise, then, as mentioned above, post a small example data (CREATE TABLE and only relevant columns, INSERT statements) for all of the tables involved and also publish outcomes from these data (that is, the content of the view).
Explain, using specific examples, how you get these results from these data.
Always say what version of Oracle you are using (for example, 11.2.0.2.0).
See the FAQ forum {message identifier: = 9360002} -
Comparing the sum of the two tables and correct by difference of amount in its second t
Hello guys,.
I have a very difficult task that I can't get my head around.
The sample data looks like this:
Master table
Request - booking - debit - credit - MasterAmout
1------------1----------------D---------------------------------15.3
1------------2----------------D---------------------------------480.6
1------------3------------------------------C-------------------496.8
------------------------------------------- 0.9
The slave table
Demande---reservation---debit---credit---slaveamout---slavecorrection
1------------1------------D------------------------------------15.3---------------14.5
1------------2------------D------------------------------------480.6-------------480.6
1------------3-----------------------------C-------------------496---------------496
-------------------------------------------0.1--------------------------------------0.9
The reservation have a total amount of 0.1, but must be corrected to 0.9 because the main table has 0.9.
Reservation 1 requires a correction so the slave table also has a total of 0.9 (business rule is, only corrections on the first booking). So we have
to change the amount of 15.3 to 14.5. I plan my SQL like this:
1 reservations sum of two tables for each claim. Compare the two for each individual claim.
2. If Captain sum the amount shows a difference between master / slave
2.1 select top 1 table reservation slave for the specific claim and increase/decrease by the difference of these two amounts.
Who is?Hello
Use MERGE to actually do the UPDATE.
The ROW_NUMBER analytic function to identify the first booking in slave (unless you can count on which the reservation = 1).MERGE INTO slave dst USING ( WITH master_summary AS ( SELECT claim , SUM ( master_ampount * CASE WHEN debit = 'D' THEN -1 WHEN credit = 'C' THEN 1 END ) AS balance FROM master GROUP BY claim ) SELECT s.claim , s.booking , SUM ( s.slave_amount * CASE WHEN s.debit = 'D' THEN -1 WHEN s.credit = 'C' THEN 1 END ) OVER (PARTITION BY claim) - m.balance AS diff , ROW_NUMBER () OVER ( PARTITION BY claim ORDER BY booking ) AS r_num FROM master_summary m JOIN slave s ON m.claim = s.claim ) src ON ( src.claim = dst.claim AND src.r_num = 1 ) WHEN MATCHED THEN UPDATE SET dst.debit = CASE WHEN src.diff < 0 THEN 'D' ELSE NULL END , dst.credit = CASE WHEN src.diff < 0 THEN NULL ELSE 'C' END , dst.slaveamount = ABS (src.diff) ;
If you would care to CREATE TABLE and INSERT statements for the sample data (showing the two tables, as they exist before the DML) then I could test this.
The design of history seems very uncomfortable. Instead of the debit and credit columns, it would be much simpler to have positive and negative amounts. Is it really worth now both not corrected and corrected the amounts in the table on the slave, especially if you keep only versions corrected debit and credit columns?
-
compare two tables and update the differences
Hi all
Sorry for the newbie question, but I am a beginner in the present.
I have two tables, both have same structure-
CODE - code NUMBER (6,0) store is the primary key does not change and is unique
ADDRESS1
ADDRESS2
ADDRESS3 - all VARCHAR2 (100)
One of the tables is named MASTER, the other being updated. MASTER contains hundreds of lines, while the table of UPDATES may have anywhere from zero to 10 or more.
I want to compare the table of UPDATES against the MASTER of the table and if there is a difference, ask the differences in the table in UPDATES to the MASTER of table - so if the address of an Exchange store, then the change is reflected in the MASTER table by crushing with the data contained in the UPDATES table.
I thought that maybe using sliders and compare each field but there must be a more efficient way.
I hope that I have explained quite clearly... any help would be greatly appreciated.
Thank you
BillEducation MERGE, assuming that your version supports supported the MERGER.
SY.
-
I have two tables;
First data table
second table also with data, but it will check with the first prod_code table, if the prod_code is not in the first table it will insert the values of the second array to the first table on the other not...
SQL > declare
2 cursor stk_val is
3 select prod_code, prod_desc, prod_tran bal_Stock;
4 mProd_code prod_tran.prod_Code%type;
prod_tran.prod_desc%type mProd_desc 5;
mProd_qty 6 prod_tran.prod_qty%type;
7 whole valexits;
8 whole bal_stock;
9 whole vquantity;
10 whole f_itemcheck;
Begin 11
12 stk_val open;
loop 13
14 stk_val of fetch in mprod_code, mprod_desc, mprod_qty;
15 exit when stk_val % notfound;
16 valexits: = f_itemcheck (mprod_code);
17 if valexits = 0 then
18. insert into prod_mast (prod_code, prod_Desc, bal_Stock)
19 values(mprod_code,mprod_Desc,mprod_qty);
20 elsif valexits = 1 then
Update 21 prod_mast
22 set bal_stock = bal_stock + vquantity
23 where prod_code = mprod_code;
24 end if;
25 end of loop;
26 close stk_Val;
27 end;
28.
Declare
*
ERROR on line 1:
ORA-06550: line 3, column 34:
PLS-00320: the declaration of the type of the expression is incomplete or incorrect
ORA-06550: line 3, column 6:
PL/SQL: SQL statement ignored
ORA-06550: line 16, column 22:
PLS-00222: no function with name 'F_ITEMCHECK' does exist in this scope
ORA-06550: line 16, column 10:
PL/SQL: Statement ignoredHello
(1) I am convinced that you can use merge ehre and avoid a slow row-by-row processing.
(2) vquantity when you set this value?For education Merge ehre is the link.
[http://www.psoug.org/reference/merge.html]See you soon!
Bobin -
How to make an update of a view online two tables...
When the unique constraint of the second table includes three columns?
I have two tables A and B and I want to update a table column, one using an update of a view online two tables.
Table A:
col1 primary key
col2
Table B:
col1 u1
col2 u2
COL3 u3
COL4
col5
Table col1 primary key, table B has a unique constraint on col1, col2 and col3.
Tables A and B are joined in this way:
And now, I want to update this view and set KEY_OLD = KEY_NEW.select A.col1, A.col2 as KEY_OLD, B.col5 as KEY_NEW from A, B where (B.col1 = 'literal_1') and (B.col2 = 'literal_2') and (A.col1 = B.col3) and (A.col2 = B.col4)
Because of the first three conditions in the where clause for each entry in the table A there is just a matching entry in the table B.
So the table should be preserved in the join key.
But during the update
I get an error ORA-01779.update (select A.col1, A.col2 as KEY_OLD, B.col5 as KEY_NEW from A, B where (B.col1 = 'literal_1') and (B.col2 = 'literal_2') and (A.col1 = B.col3) and (A.col2 = B.col4) ) set KEY_OLD = KEY_NEW;
I did the updates on inline views this way several times in recent weeks and it work very well.
But so far the unique constraint on the table B was just a column ;-)
So what I need is to make it work with the unique constraint on the application of the three-column table B.
Thank you very much in advance for any help.
Hartmut cordiallyPreserved key criteria must be met by the join columns, the optimizer does not agree (in fact I never tried in 11g) just a combination of columns, literals and join.
The alternatives you have are subqueries online (which as you point out can do rather worse), the command MERGE or indicator BYPASS_UJVC semi undocumented.
-
I need to save two tables 1 d to Excel in version 8.2
Hello
I can't find good examples for labview 8.2.
I have two tables 1 d of 1024 items. I need to save each other in another column of an excel file.
How can I do?
Thank you.
Hello
You can use the spread worksheet function to save data in Excel. File extension should be .xls as test.xls
-
I want to compare two tables and out a boolean
This should be simple. I want to compare two tables (5 items) and return a single Boolean value (T/F), not an array of Boolean.
Thank you
Kevin
Right click on the comparison, the comparison mode, select compare the aggregates.
-
Display two tables 1 d on Wavechart
Hello
How to display two tables 1 d of the same size on a WaveChart
Thank you.
No, aid is correct, if wire you a table 2D to waveform curve, you can transpose it in the context menu as follows:
Checking / unchecking this option has the same effect than to put a 2D conversion table before you wire your table in the waveform table.
-
I have two tables I want to fix the end to end. If I use the version table it creates an annexed table which is not what I want. essntially im doing the opposite of WBS. are there features that fit this description?
in fact, I just found out 'insert into array' worked for me. I'll try you method too next time
-
I have two table with 50 elements. I tried to draw a xy chart using these two tables. but the graph is not... someone can help me?
Use build to set new values in an existing table, at the end. Store the array between iterations of your loop for the use of shift registers.
-
compare two table with cluster inside
Hello
I want to compare two tables containing a cluster with several groups in it. When you use the equal the result is the same pattern as the cluster of entry. But I just need a true or false. It doesn't bother me that it changed on position 1 or any other position.
Is there an elegant way to do it?
Thanks for any help.
Yves
Right-click equality and change to compare aggregations. That, or add a table and later.
/Y
-
Combine two tables 1 d in a 2D array
Hi all
Maybe I forget what is obvious, but I can't find a solution to combine two tables 1 d in a 2D array AND (it is the impossible part for me) using the tables columns instead of lines.
Example:
Table 1:1, 2, 3, 4
Table 2:5, 6, 7, 8
Result: 1, 5
2, 6
3, 7
4, 8
The 'build array' function seems to add all tables as lines... I guess I could transpose the table, but I want it runs in a Subvi in constructions of different loop and I feel a little uncomfortable with it - I guess one would be left with a completely mixed table. I was maybe blind just to find the right function?
Cheers, Jessi
Hi Jessi,
by default, LV is combining tables in rows. So when you need columns you must transpose the sets or use a different indexing scheme...
-
Question: two tables in a pool, load balancing, etc.
Hello
So I'm sort of confused about how it works. I know I can put two tables that are part of the same group in the same pool, and I know I can create a volume that spans the two tables and the EQL will spread the volume also between two boxes, etc etc.
My question, I guess that is the reliability... Have I missed something or that seems like a "RAID 0" type thing between two EQLs? I mean, if the volume is divided between the two boxes, how can I ever do a reset on a box? What happens if one of the EQL breaks down? What I lose this entire volume?
What Miss me? Or is it how it really works?
I'm kind of fear put anything in production where a failure on a device would kill everything like that.
Any explanation would be appreciated.
The button is named "restart" and launch of a failover of the MC Eve always. Yes, there is no complete reboot option or task.
Well... is the same "risk" to have a storage with multiple heads and a few shelves of extension. If storage with Betclic or groups on disc on shelves and you lose a comprehensive shelf, you're in trouble.
In theory the risk increases if you put more members to a pool, because a volume divided on 3 volume by default. But it is a softlimit and you can adjust the distribution of volume more or less members. If you have a volume that is large and 3 members cannot provide this ability, he can go 4 or more members. The largest volume spreads i never saw in all 8 members. Spread of the volumes between the members, that's how EQL scales on.
If you do not as you turn this option off or copy your data with SyncRep option.
Kind regards
Joerg
Maybe you are looking for
-
Firefox help Search "Found 0 results for" my firefox top bar has been changed, I used to be able to get the bookmarks printed Format file, and other services that I have found useful when taking information from the internet, I found bookmarks to the
-
Channel indicator displays an incorrect value for Enum
Hello together, I have a LabView 2012 application, running for years in our production. For the visible operator, an "Active State" text indicator shows the current status, for example "Press Start Button"... From time to time I am facing following p
-
Hi all We try to start working with Tortoise SVN. I entered all the things properly in SVN settings according to them here: http://expressionflow.com/2007/08/28/using-new-labview-merge-tool-lvmerge-with-tortoisesvn/. (I tried both versions of the com
-
My Windows 7 Pro system has some serious hardware, internet connection and security issues. My efforts to remedy by restoring a system image backup failed. At this point, I'm ready for a new clean install if I have to buy a drive to do. My question