How to create a select statement to the data in two tables?
Hi all
Table 1
ID YEAR
758 2013
Table 2
ID YEAR
758 2014
I want to create some that translates into two lines: function that does this?
ID YEAR
758 2014
758 2013
Thank you, best regards.
Hello
Perhaps a select * from table1 UNION ALL select * from table2 will help you.
concerning
Kay
Tags: Database
Similar Questions
-
Kindly help me with the request to find the data in two tables
Hello Guru
Kindly help me to recover the data from two tables-
BASEBALL
LEGAL_ENT_ID (PK)
GAME_ID (FK)
LEGAL_ENT_NM
INACTIVE_DT
DATE OF INS_TS
INS_LOGIN
DATE OF UPD_TS
UPD_LOGIN
FOOTBALL
GAME_ID (PK)
BRKR_NM,
BRKR_ISR_ID
BROKER_SYMBOL
INACTIVE_DT
BRKR_SWIFT_FLG
BRKR_INTERNAL_FLG
BRKR_CATEGORY
UPD_TS
MINORITY_FLG
BROKER_TYP
STATUS
INS_TS
INS_LOGIN
UPD_LOGIN
APP_USER
ACTIVE_FLG
and if I want fecth data from these two tables according to the following condition then it is fine with the suite of applications.
1 select distinct values only table of BASEBALL by using the following query.
SELECT DISTINCT B.GAME_ID as 'CLEARING GAME ID', B.BRKR_NM "NAME of THE GAME of COMPENSATION" OF BASEBALL A, FOOTBALL B WHERE A.BROKER_RELATION_CD IN ('FUTBRKR1', 'FUTBRKR2') AND A.GAME_ID = B.GAME_ID
2 Select all the table BRKR_NM OF FOOTBALL as well by using the query - next
SELECT GAME_ID "RUNNING GAME ID", 'NAME OF THE GAME OF EXECUTION' BRKR_NM SOCCER
Now, my query is that--
I want a query that gives me a combination of above mentioned queries... and if I tried to use Union or Union All, then she is not giving me the result as expected.
I like the result to look like who has a few conditions such as -
1 - the records in the table Football are high vs Baseball table because there is no condition to filter the records of the Football.
2 - football is a superset of records and Baseball is a subset.
3 - COMPENSATION NOM_JEU and RUNNING NOM_JEU may return the same values as well.
I want the result to be in the following form-
EXECUTION ID GAME | NAME OF THE GAME TO RUN. COMPENSATION ID GAME | DELETE THE NAME OF THE GAME.
2123 test1 2345 test5
2456 test10 2456 test10
Thanks in advance. Kindly help me.
Published by: user555994 on January 4, 2011 23:48In the output you want.
All the values of baseball;
Values of football that are matched;
But on what condition you want to match? -
How to convert this select statement in the update
Hai All
I have two tables namely Daily_attend, Train_mast
The Daily_attend are made up of fields are Train_mast are made up of fields are
Name varchar form no var
Date of empcode Num V_DATE
Intimate Date Train_name var
Outtime date Late_hrs var
Number IND_IN
Number IDE_OUT
Date of Attend_date
I need to update the table Depend of IDE_IN in Daily_attend in late_hrs in the Train_mast table
I got through in the select statement, it is my select statement
Select to_number (TO_DATE (TO_CHAR(Intime,'DD-MON-YYYY') |)) » '||
To_char (0815, '0000'), 'MON-DD-YYYY HH24') + late_hrs /(24*60)-respondent
) * 24 * 60 dail_Att, train_mast;
How can I convert to update
Any help is highly appricateable
Thanks in advance
Concerning
Srikkanth.MSrikkanth,
Try this code. And 1 thing, I don't see any WHERE condition to join between the 2 tables, DAIL_ATT, TRAIN_MAST.
UPDATE DAIL_ATT A SET A.IDE_IN = (SELECT TO_NUMBER(TO_DATE(TO_CHAR(INTIME, 'DD-MON-YYYY')|| ' ' || TO_CHAR(0815, '0000'), 'DD-MON-YYYY HH24:MI') + LATE_HRS / (24 * 60) - INTIME) * 24 * 60 FROM TRAIN_MAST B WHERE
); Kind regards
Manu.
If my answer or the answer to another person has been useful or appropriate, please mark accordingly
-
How to write a select statement inside the case operator
Hi all
I want to write a query that get the result of another table of case operator.
for example
Select a, b, c of the double
where a = 1
and b = case when b is null then 'select any value from the other table' any other purpose;
Please help me to write this query.
Thank youSelect a, b, c of the double
where a = 1
and b = case when b is null then 'select any value from the other table' any other purpose;Guilty plea
Select a, b, c from tableA a
where a.a = 1
and a.b = (select decode (a.b, null, (select 1 from tableB b where rownum = 1), a.b) double) -
How to create timer thread and update the data in qml
See once again that the user selects the time then I have to open a plus qml, them what that time that the user has selected he will start him it and display in the texview of this point of time until compled times what the user has selected.
the textview should show how the change of second... That is to say all like look.
Please guide me what the correct feature I have to used?
I won't go to timer or wire?
Please guide me
Now please tell me that you are able to see the image or not?
Plese now answer the solution?
-
How to find the data in two tables are the same?
Hi people,
Suppose we have table emp01, have 10 records and create another emp02 as table
create the table emp02 in select * from emp01;
now both the table has the same data.
How to find a 'data' in the two tables are the same?Hello
SELECT * FROM emp01 MINUS SELECT * FROM emp02 UNION SELECT * FROM emp02 MINUS SELECT * FROM emp01
You can also compare resultset hash to select * in emp01 and select * from emp02 by using dbms_sqlhash.
Best regards
Nikolai -
Hello
I am trying to build a query WITH, but I can't seem to make it work:
WITH P1 AS (SELECT OT_VALUE
OF CSD_OPEN_VERY_HIGH_INCIDENTS VHIGH
WHERE OT_VALUE > = 0
). P2 AS (SELECT OT_VALUE
OF HIGH CSD_OPEN_HIGH_INCIDENTS
WHERE OT_VALUE > = 0
), SELECT VHIGH. OT_VALUE, TOP. OT_VALUE
P1 P2 JOIN INTERNALLY. RATING = P2. RANKING
The two tables have the same column names.
I want to only return a set of results if the two columns (OT_VALUE) contain in reality 1.
Select this check box. This is a job for all four images. This will return the line to the following combinations. 0.0 and 0.1 and 1.0 and 1.1. Importance is 1.2. Let me know if you face any problem
SELECT CASE WHEN ((VH_OT_VAL = 0 ET H_OT_VAL = 0) OR (VH_OT_VAL = 1 AND H_OT_VAL = 0) OR (VH_OT_VAL = 0 AND H_OT_VAL = 1) or (VH_OT_VAL = 1 AND H_OT_VAL = 1)) 1
ANOTHER ACE OF NULL TERMINATOR OT_VAL
DE)
SELECT H.OT_VALUE H_OT_VAL,
VH. OT_VALUE VH_OT_VAL
OF CSD_OPEN_VERY_HIGH_INCIDENTS VH.
CSD_OPEN_HIGH_INCIDENTS H
WHERE NVL (VH. CLASSIFICATION, 0) = NVL(H.CLASSIFICATION,0)
AND VH. IMPORTANCE IN (1,2)
AND H.IMPORTANCE IN (1,2)
AND NVL (VH. OT_GROUP, 0) = NVL(H.OT_GROUP,0)
AND VH. IMPORTANCE = H.IMPORTANCE
AND VH. TIME_STAMP = H.TIME_STAMP
);
-
Is mapping dimension AWM - possible to load the data in two tables of entry?
Hi all
I have two tables ProductFamily (parent level) and products (child level).
I want to load a dimension of those tables where the parent-child relationships are maintained (I use AWM).
I created a map with these two entry tables, but the loaded data has no relationship.
So, how do I do that? Is it possible to load dimensions where different levels get data from multiple tables?
Is any type of Carpenter available in AWM?
Thank you
------------------------
A few Notes:
-I don't want to use OWB here that my data are clean
-In AWM, when I loaded the data in a single view that contains two tables of input data, it worked fine. But it's my worst case option.You must use Dimension option in snowflake in the mapping screen of size for the Product Dimension (as opposed to the default style mapping - star schema dimension).
This will modify map entries to include a separate parent for each level of hierarchy level / that is to say, for each level of hierarchy / (unless a higher level of the hierarchy), you must specify the parent level key in addition to the key current level, code/name/description/other attributes etc.
You can make the mapping or... use the icons at the top of the map screen.
mode drag/drop by dragging the relational column on dimension - level/hierarchy/attribute model
-or-
the table expression mapping mode that gives the same effect... by dragging a column on an attribute defined in the. . the format of
. HTH
ShankarNote1: Complete the mapping of a sudden... B & w switching mapping modes cause the mappings to reset.
NOTE2: assumes that your data are correct foreign key table parent level: ProductFamily exists in the child level table: products. -
display the data in two tables.
Hi considers the following data
I want to join these two tables and result the followingWITH table1 AS ( SELECT 111 userid, To_Date('7/31/2010','mm/dd/yyyy') dt FROM dual UNION ALL SELECT 111 userid, To_Date('8/1/2010','mm/dd/yyyy') dt FROM dual UNION all SELECT 111 userid, To_Date('8/2/2010','mm/dd/yyyy') dt FROM dual UNION ALL SELECT 111 userid, To_Date('8/3/2010','mm/dd/yyyy') dt FROM dual UNION ALL SELECT 111 userid, To_Date('8/4/2010','mm/dd/yyyy') dt FROM dual UNION ALL SELECT 111 userid, To_Date('8/5/2010','mm/dd/yyyy') dt FROM dual UNION ALL SELECT 222 userid, To_Date('2/28/2010','mm/dd/yyyy') dt FROM dual UNION all SELECT 222 userid, To_Date('3/5/2010','mm/dd/yyyy') dt FROM dual UNION all ), mydates AS ( SELECT To_Date('7/31/2010','mm/dd/yyyy') dt1, To_Date('8/4/2010','mm/dd/yyyy') dt2 FROM dual UNION ALL SELECT To_Date('2/28/2010','mm/dd/yyyy') dt1, To_Date('3/5/2010','mm/dd/yyyy') dt2 FROM dual )
Basically, I join two tables, take dt from table1 and look into mydates. If the data match then display dt and DM2.DT DT2 7/31/2010 8/04/2010 8/01/2010 8/01/2010 8/02/2010 8/02/2010 8/03/2010 8/03/2010 8/04/2010 8/04/2010 8/05/2010 8/05/2010 2/28/2010 3/5/2010 3/5/2010 3/5/2010
If the date in table1 does not match date in t1d in mydates, then display the data but dt and DM2 there same date.
for example,.
7/31 in table1 is 7/31 in mydates so I show 7/31 dt and DM2 as 8/4(from mydates).
now 8/01 does not match all lines in my dates so dt should be 8/01 and T2D should be 8/01. same logic applies to the other lines
can someone write a query that gives the above result? Thank youHello
If you want all lines of table1 (attached to mydates when this is possible, but even when there is no match) then use an outer join:
SELECT t.dt , NVL (m.dt2, t.dt) AS dt2 FROM table1 t LEFT OUTER JOIN mydates m ON t.dt = m.dt1 ORDER BY t.dt ;
-
I have the data into two table with the structure of similar column, I want to loop through the data in these two tables
based on some condition and runtime that I want to put the query in loop for example, the example is given, please help me
create table ab (a number, b varchar2 (20));
Insert into ab
Select rownum, rownum. "" sample "
of the double
connect by level < = 10
create table bc (a number, b varchar2 (20));
Insert into BC.
Select rownum + 1, rownum + 1 | "" sample "
of the double
connect by level < = 10
declare
l_statement varchar2 (2000);
Boolean bool;
Start
bool: = true;
If it is true, then
l_statement: =' select * ab ';
on the other
l_statement: =' select * from bc';
end if
I'm in execute immediate l_statement - something like that, but I don't know
loop
dbms_output.put_line (i.a);
end loop;
end;
Something like that, but this isn't a peace of the code work.
Try this and adapt according to your needs:
declare
l_statement varchar2 (2000);
c SYS_REFCURSOR;
l_a number;
l_b varchar2 (20);
Boolean bool;
Start
bool: = true;
If it is true, then
l_statement: = "select a, b, AB;
on the other
l_statement: = "select a, b from bc;
end if;
--
Open c for l_statement;
--
loop
extract the c in l_a, l_b;
When the output c % notfound;
dbms_output.put_line (l_a |') -' || l_b);
end loop;
close c;
end;
/
-
Delete the data in partitioned tables
Hello
Oracle 11.2.0.3.0 version, running on Linux Enterprise.
I need to remove all the data from two tables (several 100 million lines each) that are partitioned.
(1) table 1 is a partition table have varied to a DATE column
(2) Table2 is a partition of reference table; partitioning is referenced on a relationship of foreign key to Table1 (column: key Table1.Primary)
As I have no need for data, but want to keep the structure of the table, I would ideally like to delete partitions at the same time that the deletion of the data, so that the 2 tables partitioned and empty.
Additionally, Table1 has some partitioned index I would be rebuilt as an index unpartitioned (given that Table1 will be empty).
I thought I would start by removing all partitions of Table1 (via "ALTER TABLE DROP PARTITION nom_partition Table1"), but when the script came to the last partition, I got this error message:
ORA-14083: cannot delete the only one partition of a partitioned table
ORA-06512: at "SYS." DROP_PARTITIONS', line 46
If someone could advise as to the best approach to what I want to achieve with regard to the two tables? Two tables down and recreate them then without partitions would be the easiest way?
Thanks in advance for any guidance.
If someone could advise as to the best approach to what I want to achieve with regard to the two tables? Two tables down and recreate them then without partitions would be the easiest way?
Yes - delete the tables and re-create them.
As says the exception that you cannot delete the last partition. A table is partitioned either or it is not.
There was no interest at all to use DBMS_REDEFINITION to redefine tables because you do not want the data anyway.
-
How to create a report based on the item selected from the list of selection?
Hello
I created a tables_LOV based on:
Select table_name table_name user_tab_cols r, d
where column_name like '% _type % '.
Then I created a ListOfTables page element, display in a selection list and pointing to tables_LOV.
I run the page, and I can choose the table I want in the drop-down list.
How to create a report based on the selected element? (ex: select * from selected_table)
Thanks in advance
Salah
Hi Salah,
Allright, take a look at this page: http://apex.oracle.com/pls/apex/f?p=vincentdeelen:collection_report
I think that simulates what you are trying to accomplish. I've implemented the simplest method I could think of.
The report is based on a collection of apex. If you are not familiar with this, you should study the documentation: APEX_COLLECTION
To recreate my example, you should:
(1) create a report (interactive) on your collection
SELECT * FROM APEX_collections WHERE collection_name = 'MY_COLLECTION'
(2) create a selection list page_item for the tables that you want to display (in my case, this is called "P38_TABLES")
(3) create a dynamic action that triggers on the evolution of your selection list page_item. Dynamic action must be a parade of PL/SQL procedure the following code:
declare l_query varchar2(4000); begin l_query := 'select * from '||:P38_TABLES; if apex_collection.collection_exists ( p_collection_name => 'MY_COLLECTION' ) then apex_collection.delete_collection ( p_collection_name => 'MY_COLLECTION' ); end if; apex_collection.create_collection_from_query ( p_collection_name => 'MY_COLLECTION' , p_query => l_query ); end;
Make sure that you add your page_item 'Page to send items' section.
(4) add a real extra action that makes an update of the report area.
Here are two photos describing the da:
http://www.vincentdeelen.com/images/OTN/OTN_COLLECTION_REPORT_DA1.PNG
http://www.vincentdeelen.com/images/OTN/OTN_COLLECTION_REPORT_DA2.PNG
Good luck and greetings,
Vincent
-
How to block a select statement for a table of the specified until validation line
Hello
How to block a SELECT statement for a specified row in a table until willingness to engage occure?
My procedure is part of a Stock request and if a user (X) get stock 1 piece, another user must wait for the user (Y) complete his reportoire.
So, let say my stock have 10 pencils.
When the X user starts the Stock_PLS procedure, in table Stock, line (e.g. R1) that user X should work with it, must be lock up to what the commit / rollback will appear.
procedure Stock_PLS...
Start
..
pencils: pencils-1 =;
..
End
Observation-> pencils: = 9;
This means that is a user there, run SELECT * stock of the table where rows_id = R1, SELECTION should wait the Stock_PLS started by user X will be completed (with commit or rollback) and his SELECT should return the value 9.
What I need, is that Oracle has something like LINE EXCLUSIVE TABLE LOCK, but in my situation the SELECT statement should be denied on the specified lines, until the end of the procedure.
Kind regards
MichaelHello
You can achieve this using the update with the Select clause.
You can write your select statement like this
SELECT * from stock of the table where rows_id = R1 for update; -
How to create a pick list in the navigation bar
Hello
I use apex5 universal theme and I have an obligation to create a selection list in the navigation bar (before the username and logout) and join a dynamic action. Can someone tell me please how to do this.
Note: I have created a page zero region. But none of the region of downtown suites this obligation to show the point just before the username and logout.
Thank you
Stephanie.
Guys,
I thought about a way myself. Its works fine as well. Please find the steps below.
- Create a region in page zero as a model "empty with attributes.
- Create a P0_SELECTION to a P0_SELECTION class (if you do not use this class, you can still refer with ID P0_SELECTION, your choice)
- Create a bar the entrance to the navigation list with the following properties-online class/Image = SELECTIONPOSITION, entry list Label =, Target = URL, target URL = javascript: void (0);
When you have finished the above activities, go to a page where you would like this item placed in the navigation bar. Simply put the code below in the section JS page (Execute when the Page loads).
$(". P0_SELECTION')
.appendTo(".) SELECTIONPOSITION");
The jquery above to add the item to the navigation class class. Now the best way is to designate the ID. All you need to do is change as below.
$("#P0_SELECTION")
.appendTo ("#SELECTIONPOSITION");
In this way, you can position your elements from anywhere in the page. All you need to do is to create and DISPLAY or class position and adds the element using jQuery.
Hope this information is useful for someone struggling to position elements in the Web page.
Thank you
Stephanie.
-
How to create a selection from a form on a transparency?
I watched the video of Corey Barker "Adobe Photoshop: from scratch." Of the great stuff, except that it does the same thing in two different segments without explaining what it was - a real show-stopper for a beginner like me.
E.g. "Lights" at 03:07. Here, he takes a transparency layer with a shape to this topic and creates a selection out of this shape/object, since he later creates a layer mask on another layer.
I'm sure that it's simple, but exactly how do you create a selection out of the shape of an object that is on a transparency? Thank you.
Press command (clover), then click on the layer icon in the layers panel. Or go to Select > load selection > layer of transparency (with the desired layer highlighted in blue in the layers panel).
Maybe you are looking for
-
SIRI remote no longer meets its
When I first set up my TY Apple (4th Gen) the SIRI remote worked perfectly, I don't know when exactly it has stopped working, but now if I press the Microphone button, the TV responds and shows the bar of SIRI, but it not modulated and continues to g
-
Since Firefox 4.0 installed, I seem to have problems with my browser of Google/ig page and need to connect again after that Firefox is closed, then restarted.
-
Battery recently out faster and iPhone stops at 9%
Hello first of all, of all the technical features of my camera. I use an iPhone with 64 GB 6. iOS 9.2 is installed. I have the iPhone for a little over a year. Now to my problem. In recent weeks, I have problems with my battery. It wears out much mor
-
change the text in Notepad so its readable
I open a file in Notepad and put into shape but its always unreadable text could just one out there help me please thank you
-
exclusion of the individual form?
How to combine individual forms? I have 3 circles without a fill color, only the race and I want to combine them, then I can exclude/cut a diamond from the outside shape.Here is a picture of preference:Basically, my real question is, how I cut the di