display the data in two tables.

Hi considers the following data
WITH 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 
)
I want to join these two tables and result the following
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
Basically, I join two tables, take dt from table1 and look into mydates. If the data match then display dt and DM2.
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 you

Hello

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
;

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:48

    In 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 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

  • 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
    Shankar

    Note1: 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.

  • Select the data in two tables

    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

    );

  • 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

  • I want to loop through the data from two different tables using for loop where the query should be replaced at runtime, please help me

    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.

  • call a stored procedure for each row in the transitional attribute and display the data in the form of af: table. The other rows are based on the entities

    Hi Experts,

    JDeveloper 12.1.3.0.0

    I have a VO based on entity object. With a column of the VO is transient attribute (I created).

    I need to call a stored procedure for each row in the transitional attribute and display the data in the form of af: table. As well as other attributes.

    So can anyone suggest how can I achieve this?

    Thank you

    AR

    I think that you need a stored function (which returns the value) in this case, is not?

    Take a look at:

    https://docs.Oracle.com/CD/B31017_01/Web.1013/b25947/bcadvgen005.htm

    and search for:

    Invoking stored function with only Arguments in

    call your function in the Get attribute and return value accessor...

  • clock in the notifications box no longer displays the date beneith the time

    Series HP Pavilion HPE h8 - 1360t running Win 7

    When I ran Setup and decided that I needed to install the software, I notice that the date is now displayed in the tray under the era.  I was happy that I is no longer my clock application to display the date.

    Now that I've installed all the updates and my usual software, the clock in the notification area displays only the time.  The date seems to have disappeared.

    I don't know what I've done or installed to make it disappear.  I can't find a way to recover.

    Is there a software switch somewhere that turns on the display of the date of the clock?

    Normally, the 'taskbar' are a height of 'one'... the time is displayed. If you unlocked the "taskbar" and stretch up to a height of 'two'... the time, day and date will be displayed. Thereafter, be sure to lock the taskbar to prevent change.

    Please send Bravo

  • concatenate the data in 2 tables in a third table as well as in CONCATENATE strings

    Hello. as the title says, I wish to only concatenate the data in 2 tables in a similar third table that concatenate strings don't. All tables should be 1 d. For example, suppose that there is 1 table with the following: 1. 2; 3; 4 and table 2 with:; b; c; d. I would like a table 3 either 1 a, 2 b, 3 c, 4 d. Now this could be done easily with above mentioned concatenate strings, then table construction. but table 1 and 2 have something like 150 items. Rather painful. Any ideas?

    Hold arrays of two strings in a loop for example, concatentate the strings inside the loop and run the result réécrirait array3.

    Autoindexing manages table manipulations.

    MIke...

  • My user folder displays the data of 30 GB. Actual data are only 2 GB. I want to wipe my drive C of hidden data. How can I get the details of 30 GB of data shown in the properties of the folder

    My user folder displays the data of 30 GB. Actual data are only 2 GB. I want to wipe my drive C of hidden data. How can I get the details of 30 GB of data shown in the properties of the folder.

    Hello

    This free program allows you to see what is taking place.

    http://www.Jam-software.com/treesize_free/

    Here's how to understand Treesize Screenshots:

    http://www.Jam-software.com/treesize_free/screenshots.shtml

    ____________________________________

    Also check how much space system restore uses:

    http://Windows.Microsoft.com/en-us/Windows7/how-much-disk-space-does-System-Restore-require

    _____________________________________

    You can clean your hard drive using these two methods.

    "Delete files using Disk Cleanup"

    http://Windows.Microsoft.com/en-us/Windows/delete-files-using-disk-cleanup#delete-files-using-disk-cleanup=Windows-7

    Using the free CCleaner program:

    http://www.Piriform.com/CCleaner

    In NO case use the registry cleaning Option in CCleaner

    _____________________________________

    Download, install, update and scan your system with the free version of Malwarebytes AntiMalware:

    http://www.Malwarebytes.org/products/malwarebytes_free

    And Norton Backup, if you are using Norton, can do strange things with filling of hard drive space.

    See you soon.

  • How to display the data, that contains non-numeric characters.

    Hello

    I have table t1 with column of type varchar2 below

    ID

    ------

    11151

    11412

    1113

    1 to 114

    11b 15

    111 6

    Now, I need to display the data, that contains non-numeric characters.

    Did you get the result like:

    STR

    ----------

    1 to 114

    11b 15

    111 6

    WITH t
         AS (SELECT '11151' str FROM DUAL
             UNION ALL
             SELECT '11412' FROM DUAL
             UNION ALL
             SELECT '1113' FROM DUAL
             UNION ALL
             SELECT '1a114' FROM DUAL
             UNION ALL
             SELECT '11b15' FROM DUAL
             UNION ALL
             SELECT '111c6' FROM DUAL)
    SELECT *
      FROM t
      where regexp_like(str,'[^[:digit:]]');
    

    See you soon,.

    Manik.

  • PivotTable ' display the data as "percentage of accuracy

    Hello

    I would like to know if there is a way to configure the PivotTable ' display the data sub - percentage of ' precision.

    ATM, I have reports using SR types where one of those who are much bigger than others... Thus, when its generated report, it returns something like:

    TYPE A: 99%
    TYPE B: 0%
    TYPE C: 0%
    TYPE D: 0%

    How can I view other correct value types? Something like number of decimals...

    PS: as criteria in this report, I changed my data Format 'Number', ' less:-123 "to 15 decimal places.»

    Thank you
    Ramon

    902360 wrote:
    Hello

    I would like to know if there is a way to configure the PivotTable ' display the data sub - percentage of ' precision.

    ATM, I have reports using SR types where one of those who are much bigger than others... Thus, when its generated report, it returns something like:

    TYPE A: 99%
    TYPE B: 0%
    TYPE C: 0%
    TYPE D: 0%

    How can I view other correct value types? Something like number of decimals...

    PS: as criteria in this report, I changed my data Format 'Number', ' less:-123 "to 15 decimal places.»

    Thank you
    Ramon

    Well Yes. Can do. Read this link:

    http://shivabizint.WordPress.com/2008/09/14/changing-the-precession-of-percent-of-columns-in-pivot-table-of-OBIEE/

  • How to display the data items in the header of tempalte

    Hello friends
    I have this date_from and date date_to parameters which are parameters that the user enters...
    based on these parameters of date, I want to display in the header as
    date_from day (for example if the date_from is 13 - nov - 2010.then I should see 13) and date_to to display as 15, if for example the user enters
    November 16, 2010. (day of the date-1)
    so it should break down for
    date_from-13-nov-2010, 13
    date_to-16-nov-2010, 15
    I want these two values to display in the header of the template how
    pls help
    also let me know how to display the data items in the header template

    Published by: Les on Dec 22, 2010 12:44 AM

    Use and

Maybe you are looking for

  • Dell Inspiron 15 5000 came with Dell Webcam Central.

    Hello My Inspiron 15 5000 came with Dell Webcam Central preinstalled as it should. I checked my Dell downloads, but it is not there on the list of downloadable software. Anyone know how can I get Webcam Central? Thank you.

  • UP2715K - calibration, color, brightness, yellowish tint bright pixel

    Hello. I have several questions about the UP2715K, which I have two. My first display was a bright pixel, but also on all modes of color white point almost perfect preserves, even at 50% brightness in SRGB. My second screen has no bright pixel, but a

  • HOW TO SOLVE: OBJECT VARIABLE OR BLOCK VARIABLE NOT THE VALUE

    Please, I'm trying to snap the passport of students using my pc webcam to a program that I use to register candidates for the exam. But as I break their passport, I had this object variable of error message or with block not set. Please tell me how t

  • Error in installing windows 7 x 64

    Last night, I downloaded windows 7 ultimate x 64. Today, I started the installation and got stuck to the expansion of the files. I used this iso ongoing and worked but now gives me the error code 0 x 80070570. I tried this on a laptop that I have got

  • The user profile Service Service failed when connecting: Windows 7, SBS2011

    Hello I've been looking for an answer for the last day and hoping someone can point me in the right direction. I've seen many posts on this problem, but none of them seem to be the same as the situation that I am, if I missed an I'm sorry. We have ju