Extract single line transformed from two tables

I have two tables T1 and T2 with the same set of columns. The columns are C1, C2, C3, COND1. I need to issue a query that returns a line transformed in order to respect the following rules:

1. the returned line may contain values from both tables based on the values of column in table T1.

2 return the column C1 in table T1; If it is NULL, then return to any value is present in the column C1 of T2.

3. article 2 above apply to all columns like C1, C2 etc.

I published the following query. The problem is that if a subquery does not reach the entire query fails. Someone help me please. Probably there is another simple method.

SELECT NVL (T1.c1, T2.c1) c1, c2 (T1.c2, T2.c2) NVL NVL (T1.c3, T2.c3) c3

FROM (SELECT c1, c2, c3

FROM T1

WHERE cond1 = 'T10') T1

(SELECT c1, c2, c3

THE T2

WHERE cond1 = "T200") T2;

Hello

user4274403 wrote:

I have two tables T1 and T2 with the same set of columns. The columns are C1, C2, C3, COND1. I need to issue a query that returns a line transformed in order to respect the following rules:

1. the returned line may contain values from both tables based on the values of column in table T1.

2 return the column C1 in table T1; If it is NULL, then return to any value is present in the column C1 of T2.

3. article 2 above apply to all columns like C1, C2 etc.

I published the following query. The problem is that if a subquery does not reach the entire query fails. Someone help me please. Probably there is another simple method.

SELECT NVL (T1.c1, T2.c1) c1, c2 (T1.c2, T2.c2) NVL NVL (T1.c3, T2.c3) c3

FROM (SELECT c1, c2, c3

FROM T1

WHERE cond1 = 'T10') T1

(SELECT c1, c2, c3

THE T2

WHERE cond1 = "T200") T2;

Are you saying that if there is no row in t1 that satisfy the condition cond1 = "T10", then you want to keep seeing the lines (and values) of the t2?

And even, if there is no row in t2 that satisfy the cond1 = "T200" condition, then you want to keep seeing the lines (and values) from t1?

If so, this looks like a job for a full outer join.

You can change the join in a full outer join as follows:

SELECT NVL (T1.c1, T2.c1) AS c1

, NVL (T1.c2, T2.c2) C2

NVL (T1.c3, T2.c3) AS c3

FROM T1

FULL OUTER JOIN T2 ON t1.cond1 = 'T10 '.

AND t2.cond1 = 'T200.

WHERE t1.cond1 = 'T10 '.

OR t2.cond1 = "T200"

;

If you would care to post CREATE TABLE and INSERT instructions for some examples of data, then I could test this.

What happens if no table has all the lines that have good values in cond1?

Tags: Database

Similar Questions

  • Extraction of data from two tables without discounting

    Hi friends,

    I have a problem I want to extract data from two tables without discount in the text field when I will enter any value in a text field, then the value of corressponding must come to textfield corressponding.

    for example. There are two table A and B.
    Table A has Colunm

    S_ID number;
    C_ID Varchar2 (30);
    VARCHAR2 (4) s;

    Second table B Colunm name

    S_ID number;
    What varchar (30);
    L_Name varchar (20);

    When I enter in a text field then the c_id 101 s_id, dry, first_name and last_name should come to corressponding text without refresh fields.

    How can I do that.

    Thank you
    Maury

    You can use Ajax and there are tons of good examples out there for this purpose;
    For example [http://apex.oracle.com/pls/otn/f?p=31517:236:1876567353842241]

  • Several lines to a format of columns from two tables

    Oracle Database 11 g Enterprise Edition Release 11.1.0.7.0 - 64 bit Production

    The difficulty to return several lines simple lines/columns in two tables.

    Table 1:

    ID BOOK_NBR
    1 1001
    1 2001
    2 1010
    3 1020

    Table 2:

    AUTHOR BOOK_NBR
    1001 JOHN_1
    2001 JOHN_2
    MARY 1010
    1020 JUNE


    Desired output:

    ID BOOK_NBR AUTHOR BOOK_NBR AUTHOR
    1 1001 JOHN_1 2001 JOHN_2
    2 MARY 1010
    3-1020 JUNE


    There are an unknown number of BOOK_NBR to one ID.

    Any guidance would be appreciated.
  • Single line based on two columns and a single column

    Dear members,

    I have a table that contains duplicate rows, for which a request should be able to extract the unique row in the table. Here the unique is not based on a single column, but it should be in two columns and also check on the uniqueness on a column.

    create table addr (varchar2 (10) firstname, lastname varchar2 (10), area varchar2 (3));

    insert into values addr ('bob', 'james', 1');
    insert into values addr ('bob', 'james', 1');

    insert into values addr ('harry', 'bert', ' 1');
    insert into values addr ('jimmy', 'bert', ' 1');

    insert into values addr ('sam', 'mac', '1');
    insert into values addr ('sam', 'Knight', '1');

    insert into values addr ('tom', 'sand', '1');
    insert into values addr ("cat", "mud", "1");


    The query output must contain 3 lines.

    Bob - james
    Harry - bert or jimmy - bert [or the other of them], but not both
    -Mac or sam - Sam Knight [or the other of them], but not both
    Tom - sand
    Cat - mud

    SELECT firstname, lastname as total area WHERE addr = '1' GROUP by firstname, lastname; It takes no duplication of single column...

    Any suggestions...
    SQL> with t_data
    as
    (
    select 'bob' as firstname, 'james' as lastname, '1' as area from dual union all
    select 'bob', 'james', '1' from dual union all
    select 'harry', 'bert', '1' from dual union all
    select 'jimmy', 'bert', '1' from dual union all
    select 'sam', 'mac', '1' from dual union all
    select 'sam', 'knight', '1' from dual union all
    select 'tom', 'sand', '1' from dual union all
    select 'cat', 'mud', '1' from dual
    )
    SELECT
            firstname,
            lastname,
            area
    FROM
            (
                    SELECT
                            t.*,
                            row_number() over(partition BY firstname order by 1) rn,
                            row_number() over(partition BY lastname order by 1) rn1
                    FROM
                            t_data t
            )
    WHERE
            rn     = 1
    AND rn1 =1 ;  
    
    FIRSTNAME       LASTNAME        AREA
    --------------- --------------- ----------
    bob             james           1
    cat             mud             1
    jimmy           bert            1
    sam             knight          1
    tom             sand            1
    
    SQL>
    
  • Display data from two tables based on date criteria

    Hi all

    I have two tables, using these two tables and a few conditions I want to recover under result. Oracle version is (Oracle9i Enterprise Edition Release 9.2.0.8.0 - 64 bit Production)
    LOGON_ID        USER_ID       LOGON_TIME                 LOGON_TYPE    SUBSCRIBER_NO               CUSTOMER_ID
    
    26063548     4528890298   4/5/2010 12:03:58 AM            MSISDN       GSM04528890298              581751708
    logon_histories_r table records the information of each user who connects to the system. Subscriber Details table contains all the information corresponding to subscriber_no, only 1 row should be returned.
    I'm confused usage date condition for the table of the Subscriber, the input parameter date 04/04/2006 to 15/04/06

    Select lh.logon_id, lh.user_id, lh.logon_time, lh.logon_type, subs.subscriber_no, subs.customer_id
    of logon_histories_r lh, subscribed subs
    where lh.logon_time > = to_date('05-04-2010','dd-mm-yyyy')--to_date('04-04-2006','dd-mm-yyyy')
    and lh.logon_time < to_date('06-04-2010','dd-mm-yyyy')--to_date('15-01-2007','dd-mm-yyyy')
    and lh.user_id = substr (subs.subscriber_no,-10);

    If the date range is 04/05/2010 to 04/06/2010 then the data related to the BAN 581751708 must be the result,
    If the date range is 04/04/2006 to 15/01/2007 data related to the BAN 502499502 must be the result.

    Please find DDL and data relevant to these results. There are millions of records of Subscriber & logon_histories_r table, I am given appropriate providing a subscriber_id.

    CREATE TABLE LOGON_HISTORIES_R
    (
      LOGON_ID       NUMBER(12)                     NOT NULL,
      USER_ID        VARCHAR2(15 BYTE)              NOT NULL,
      LOGON_TIME     DATE                           NOT NULL,
      LOGOUT_TIME    DATE,
      LOGOUT_METHOD  VARCHAR2(15 BYTE),
      LOGON_TYPE     VARCHAR2(15 BYTE)              DEFAULT 'MSISDN'
    );
    
    CREATE TABLE SUBSCRIBER
    (
      SUBSCRIBER_NO           VARCHAR2(20 BYTE)     NOT NULL,
      CUSTOMER_ID             NUMBER(9)             NOT NULL,
      SYS_CREATION_DATE       DATE                  NOT NULL,
      SYS_UPDATE_DATE         DATE,
      OPERATOR_ID             NUMBER(9),
      APPLICATION_ID          CHAR(6 BYTE),
      DL_SERVICE_CODE         CHAR(5 BYTE)          NOT NULL,
      DL_UPDATE_STAMP         NUMBER(4),
      EFFECTIVE_DATE          DATE                  NOT NULL,
      INIT_ACTIVATION_DATE    DATE                  NOT NULL,
      SUB_STATUS              CHAR(1 BYTE)          NOT NULL,
      SUB_STATUS_DATE         DATE                  NOT NULL,
      ORIGINAL_INIT_DATE      DATE                  NOT NULL,
      SUB_STATUS_LAST_ACT     CHAR(3 BYTE),
      SUB_STATUS_RSN_CODE     CHAR(4 BYTE),
      PRODUCT_TYPE            CHAR(3 BYTE),
      CUSTOMER_BAN            NUMBER(9),
      CTN_SEQ_NO              NUMBER(9),
      REQ_ST_GRACE_PERIOD     DATE,
      REQ_END_GRACE_PERIOD    DATE,
      COMMIT_START_DATE       DATE,
      COMMIT_END_DATE         DATE,
      COMMIT_REASON_CODE      CHAR(3 BYTE),
      COMMIT_ORIG_NO_MONTH    NUMBER(3),
      SUSP_RC_RATE_TYPE       CHAR(1 BYTE),
      CONTRACT_NO             VARCHAR2(10 BYTE),
      CNT_SEQ_NO              NUMBER(9),
      DEALER_CODE             CHAR(5 BYTE),
      ORG_DEALER_CODE         CHAR(5 BYTE),
      SALES_AGENT             CHAR(5 BYTE),
      ORG_SALES_AGENT         CHAR(5 BYTE),
      REQ_DEPOSIT_AMT         NUMBER(13,2),
      LEADING_NUMBER          VARCHAR2(20 BYTE),
      PABX_IND                CHAR(1 BYTE),
      NEXT_CTN                VARCHAR2(20 BYTE),
      NEXT_CTN_CHG_DATE       DATE,
      PRV_CTN                 VARCHAR2(20 BYTE),
      PRV_CTN_CHG_DATE        DATE,
      NEXT_BAN                NUMBER(9),
      NEXT_BAN_MOVE_DATE      DATE,
      PRV_BAN                 NUMBER(9),
      PRV_BAN_MOVE_DATE       DATE,
      SUB_STS_ISSUE_DATE      DATE,
      ACTIVATE_WAIVE_RSN      CHAR(6 BYTE),
      EARLIEST_ACTV_DATE      DATE,
      SUB_ACTV_LOCATION       CHAR(4 BYTE),
      CUST_WATCH_LMT          NUMBER(11,2),
      CUST_WATCH_DATE         DATE,
      BASIC_WATCH_LMT         NUMBER(11,2),
      CREDIT_WATCH_PIN_CD     NUMBER(4),
      SUB_MARKET_CODE         CHAR(3 BYTE)          NOT NULL,
      LIMIT_RESERVED_DAYS     NUMBER(4),
      FF_EXPIRATION_DATE      DATE,
      FLEX_IND                CHAR(1 BYTE),
      DUO_IND                 CHAR(1 BYTE),
      LISTED_IND              CHAR(1 BYTE),
      SUB_DEPARTMENT_CD       CHAR(4 BYTE),
      LAST_SUBS_DISC_DT       DATE,
      LAST_SUBS_DISC_DT_UD    DATE,
      LAST_SUBSCR_DISC_SN     NUMBER(3),
      LAST_SUBSCR_DISC_SN_UD  NUMBER(3),
      PNI                     VARCHAR2(10 BYTE),
      RMS_REF_STORE_ID        CHAR(4 BYTE),
      RMS_REF_TYPE            CHAR(1 BYTE),
      RMS_REF_OD              NUMBER(9),
      DLR_ACT_FEE             NUMBER(11,2),
      PREP_AMOUNT             NUMBER(11,2),
      SUBSCRIBER_ID           NUMBER(9)             NOT NULL,
      SUB_LANG                CHAR(2 BYTE),
      SMS_RCV_STYLE_CODE      CHAR(2 BYTE),
      CONV_RUN_NO             NUMBER(3),
      ALLOW_ADVERTISING_IND   CHAR(1 BYTE),
      IVR_WRONG_ACCESS_NO     NUMBER(2),
      THRESHOLD_AMT           NUMBER(11,2),
      PUBLISH_LEVEL           CHAR(30 BYTE),
      AUTO_RELEASE_IND        CHAR(1 BYTE),
      CUST_WATCH_EFF_DATE     DATE,
      CUST_WATCH_EXP_DATE     DATE,
      OPERATOR_CW_LMT         NUMBER(11,2),
      SEND_SMS_FOR_MATCH      CHAR(1 BYTE),
      CPS_STATUS              CHAR(1 BYTE),
      CPS_TRANSACTION         NUMBER(3),
      CPS_TYPE                NUMBER(3),
      ISP_PASS                VARCHAR2(30 BYTE),
      ISP_TYPE                CHAR(2 BYTE),
      OPERATOR_TMP_DATE       DATE,
      OPERATOR_TMP_LMT        NUMBER(11,2),
      SUB_ORG_CD              CHAR(10 BYTE),
      ORG_MEMBER_NO           VARCHAR2(20 BYTE)
    );
    
    Insert into LOGON_HISTORIES_R
       (LOGON_ID, USER_ID, LOGON_TIME, LOGOUT_TIME, LOGOUT_METHOD, LOGON_TYPE)
     Values
       (26063548, '4528890298', TO_DATE('04/05/2010 00:03:58', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('04/05/2010 00:06:58', 'MM/DD/YYYY HH24:MI:SS'),  NULL, 
        'MSISDN');
    
    Insert into logon_histories_r
       (LOGON_ID, USER_ID, LOGON_TIME, LOGOUT_TIME, LOGOUT_METHOD, LOGON_TYPE)
     Values
       (2649592, '4528890298', TO_DATE('04/10/2006 19:19:20', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('04/10/2006 19:19:48', 'MM/DD/YYYY HH24:MI:SS'), 'TIMEOUT', 
        'MSISDN');
    
    
    
    Insert into SUBSCRIBER
       (SUBSCRIBER_NO, CUSTOMER_ID, SYS_CREATION_DATE, SYS_UPDATE_DATE, OPERATOR_ID, APPLICATION_ID, DL_SERVICE_CODE, DL_UPDATE_STAMP, EFFECTIVE_DATE, INIT_ACTIVATION_DATE, SUB_STATUS, SUB_STATUS_DATE, ORIGINAL_INIT_DATE, SUB_STATUS_LAST_ACT, SUB_STATUS_RSN_CODE, PRODUCT_TYPE, CUSTOMER_BAN, CTN_SEQ_NO, REQ_ST_GRACE_PERIOD, REQ_END_GRACE_PERIOD, COMMIT_START_DATE, COMMIT_END_DATE, COMMIT_REASON_CODE, COMMIT_ORIG_NO_MONTH, SUSP_RC_RATE_TYPE, CONTRACT_NO, CNT_SEQ_NO, DEALER_CODE, ORG_DEALER_CODE, SALES_AGENT, ORG_SALES_AGENT, REQ_DEPOSIT_AMT, LEADING_NUMBER, PABX_IND, NEXT_CTN, NEXT_CTN_CHG_DATE, PRV_CTN, PRV_CTN_CHG_DATE, NEXT_BAN, NEXT_BAN_MOVE_DATE, PRV_BAN, PRV_BAN_MOVE_DATE, SUB_STS_ISSUE_DATE, ACTIVATE_WAIVE_RSN, EARLIEST_ACTV_DATE, SUB_ACTV_LOCATION, CUST_WATCH_LMT, CUST_WATCH_DATE, BASIC_WATCH_LMT, CREDIT_WATCH_PIN_CD, SUB_MARKET_CODE, LIMIT_RESERVED_DAYS, FF_EXPIRATION_DATE, FLEX_IND, DUO_IND, LISTED_IND, SUB_DEPARTMENT_CD, LAST_SUBS_DISC_DT, LAST_SUBS_DISC_DT_UD, LAST_SUBSCR_DISC_SN, LAST_SUBSCR_DISC_SN_UD, PNI, RMS_REF_STORE_ID, RMS_REF_TYPE, RMS_REF_OD, DLR_ACT_FEE, PREP_AMOUNT, SUBSCRIBER_ID, SUB_LANG, SMS_RCV_STYLE_CODE, CONV_RUN_NO, ALLOW_ADVERTISING_IND, IVR_WRONG_ACCESS_NO, THRESHOLD_AMT, PUBLISH_LEVEL, AUTO_RELEASE_IND, CUST_WATCH_EFF_DATE, CUST_WATCH_EXP_DATE, OPERATOR_CW_LMT, SEND_SMS_FOR_MATCH, CPS_STATUS, CPS_TRANSACTION, CPS_TYPE, ISP_PASS, ISP_TYPE, OPERATOR_TMP_DATE, OPERATOR_TMP_LMT, SUB_ORG_CD, ORG_MEMBER_NO)
     Values
       ('GSM04528890298', 110069191, TO_DATE('12/04/2001 17:06:17', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('01/01/2004 22:42:49', 'MM/DD/YYYY HH24:MI:SS'), NULL, 
        'FUTRX ', 'CS016', NULL, TO_DATE('01/02/2004 00:08:32', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('07/31/2000 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), 
        'C', TO_DATE('01/02/2004 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('07/31/2000 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), 'CAN', 'CNP3', 
        'GSM', 110069191, 7013986, NULL, NULL, 
        TO_DATE('07/31/2000 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('01/31/2001 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), 'PPD', 6, NULL, 
        NULL, 1008631, 'DCNV ', 'DCNV ', 'DFLT ', 
        'DFLT ', 0, NULL, 'S', NULL, 
        NULL, NULL, NULL, NULL, NULL, 
        NULL, NULL, TO_DATE('01/02/2004 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), NULL, TO_DATE('07/31/2000 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), 
        'TEMO', 0, NULL, 0, NULL, 
        'TEL', NULL, NULL, 'N', 'N', 
        'Y', NULL, NULL, NULL, NULL, 
        NULL, NULL, NULL, NULL, NULL, 
        0, 0, 8635, 'DK', '01', 
        1, 'N', NULL, 0, '1234', 
        NULL, NULL, NULL, NULL, NULL, 
        NULL, NULL, NULL, NULL, NULL, 
        NULL, NULL, NULL, NULL);
    Insert into SUBSCRIBER
       (SUBSCRIBER_NO, CUSTOMER_ID, SYS_CREATION_DATE, SYS_UPDATE_DATE, OPERATOR_ID, APPLICATION_ID, DL_SERVICE_CODE, DL_UPDATE_STAMP, EFFECTIVE_DATE, INIT_ACTIVATION_DATE, SUB_STATUS, SUB_STATUS_DATE, ORIGINAL_INIT_DATE, SUB_STATUS_LAST_ACT, SUB_STATUS_RSN_CODE, PRODUCT_TYPE, CUSTOMER_BAN, CTN_SEQ_NO, REQ_ST_GRACE_PERIOD, REQ_END_GRACE_PERIOD, COMMIT_START_DATE, COMMIT_END_DATE, COMMIT_REASON_CODE, COMMIT_ORIG_NO_MONTH, SUSP_RC_RATE_TYPE, CONTRACT_NO, CNT_SEQ_NO, DEALER_CODE, ORG_DEALER_CODE, SALES_AGENT, ORG_SALES_AGENT, REQ_DEPOSIT_AMT, LEADING_NUMBER, PABX_IND, NEXT_CTN, NEXT_CTN_CHG_DATE, PRV_CTN, PRV_CTN_CHG_DATE, NEXT_BAN, NEXT_BAN_MOVE_DATE, PRV_BAN, PRV_BAN_MOVE_DATE, SUB_STS_ISSUE_DATE, ACTIVATE_WAIVE_RSN, EARLIEST_ACTV_DATE, SUB_ACTV_LOCATION, CUST_WATCH_LMT, CUST_WATCH_DATE, BASIC_WATCH_LMT, CREDIT_WATCH_PIN_CD, SUB_MARKET_CODE, LIMIT_RESERVED_DAYS, FF_EXPIRATION_DATE, FLEX_IND, DUO_IND, LISTED_IND, SUB_DEPARTMENT_CD, LAST_SUBS_DISC_DT, LAST_SUBS_DISC_DT_UD, LAST_SUBSCR_DISC_SN, LAST_SUBSCR_DISC_SN_UD, PNI, RMS_REF_STORE_ID, RMS_REF_TYPE, RMS_REF_OD, DLR_ACT_FEE, PREP_AMOUNT, SUBSCRIBER_ID, SUB_LANG, SMS_RCV_STYLE_CODE, CONV_RUN_NO, ALLOW_ADVERTISING_IND, IVR_WRONG_ACCESS_NO, THRESHOLD_AMT, PUBLISH_LEVEL, AUTO_RELEASE_IND, CUST_WATCH_EFF_DATE, CUST_WATCH_EXP_DATE, OPERATOR_CW_LMT, SEND_SMS_FOR_MATCH, CPS_STATUS, CPS_TRANSACTION, CPS_TYPE, ISP_PASS, ISP_TYPE, OPERATOR_TMP_DATE, OPERATOR_TMP_LMT, SUB_ORG_CD, ORG_MEMBER_NO)
     Values
       ('GSM04528890298', 502499502, TO_DATE('12/05/2006 15:55:13', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('01/12/2007 00:45:22', 'MM/DD/YYYY HH24:MI:SS'), NULL, 
        'FUTRX ', 'CS058', NULL, TO_DATE('01/12/2007 00:45:22', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('12/05/2006 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), 
        'C', TO_DATE('01/12/2007 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('12/05/2006 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), 'CCN', 'NP  ', 
        'GSM', 502499502, 14419730, NULL, NULL, 
        TO_DATE('12/05/2006 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('06/04/2007 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), 'PPD', 6, NULL, 
        '1035393', 6976424, '2311 ', '2311 ', 'DFLT ', 
        'DFLT ', NULL, '045', 'S', 'GSM04525210338', 
        TO_DATE('01/12/2007 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), NULL, NULL, NULL, NULL, 
        NULL, NULL, TO_DATE('01/12/2007 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), NULL, TO_DATE('12/05/2006 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), 
        'TEMO', NULL, NULL, NULL, NULL, 
        'TEL', NULL, NULL, 'N', 'N', 
        'Y', NULL, NULL, NULL, NULL, 
        NULL, NULL, NULL, NULL, NULL, 
        NULL, NULL, 6834900, 'DK', '01', 
        NULL, 'N', NULL, 9999999.99, '4321', 
        NULL, NULL, NULL, NULL, NULL, 
        NULL, NULL, NULL, NULL, NULL, 
        NULL, NULL, NULL, NULL);
    Insert into SUBSCRIBER
       (SUBSCRIBER_NO, CUSTOMER_ID, SYS_CREATION_DATE, SYS_UPDATE_DATE, OPERATOR_ID, APPLICATION_ID, DL_SERVICE_CODE, DL_UPDATE_STAMP, EFFECTIVE_DATE, INIT_ACTIVATION_DATE, SUB_STATUS, SUB_STATUS_DATE, ORIGINAL_INIT_DATE, SUB_STATUS_LAST_ACT, SUB_STATUS_RSN_CODE, PRODUCT_TYPE, CUSTOMER_BAN, CTN_SEQ_NO, REQ_ST_GRACE_PERIOD, REQ_END_GRACE_PERIOD, COMMIT_START_DATE, COMMIT_END_DATE, COMMIT_REASON_CODE, COMMIT_ORIG_NO_MONTH, SUSP_RC_RATE_TYPE, CONTRACT_NO, CNT_SEQ_NO, DEALER_CODE, ORG_DEALER_CODE, SALES_AGENT, ORG_SALES_AGENT, REQ_DEPOSIT_AMT, LEADING_NUMBER, PABX_IND, NEXT_CTN, NEXT_CTN_CHG_DATE, PRV_CTN, PRV_CTN_CHG_DATE, NEXT_BAN, NEXT_BAN_MOVE_DATE, PRV_BAN, PRV_BAN_MOVE_DATE, SUB_STS_ISSUE_DATE, ACTIVATE_WAIVE_RSN, EARLIEST_ACTV_DATE, SUB_ACTV_LOCATION, CUST_WATCH_LMT, CUST_WATCH_DATE, BASIC_WATCH_LMT, CREDIT_WATCH_PIN_CD, SUB_MARKET_CODE, LIMIT_RESERVED_DAYS, FF_EXPIRATION_DATE, FLEX_IND, DUO_IND, LISTED_IND, SUB_DEPARTMENT_CD, LAST_SUBS_DISC_DT, LAST_SUBS_DISC_DT_UD, LAST_SUBSCR_DISC_SN, LAST_SUBSCR_DISC_SN_UD, PNI, RMS_REF_STORE_ID, RMS_REF_TYPE, RMS_REF_OD, DLR_ACT_FEE, PREP_AMOUNT, SUBSCRIBER_ID, SUB_LANG, SMS_RCV_STYLE_CODE, CONV_RUN_NO, ALLOW_ADVERTISING_IND, IVR_WRONG_ACCESS_NO, THRESHOLD_AMT, PUBLISH_LEVEL, AUTO_RELEASE_IND, CUST_WATCH_EFF_DATE, CUST_WATCH_EXP_DATE, OPERATOR_CW_LMT, SEND_SMS_FOR_MATCH, CPS_STATUS, CPS_TRANSACTION, CPS_TYPE, ISP_PASS, ISP_TYPE, OPERATOR_TMP_DATE, OPERATOR_TMP_LMT, SUB_ORG_CD, ORG_MEMBER_NO)
     Values
       ('GSM04528890298', 581751708, TO_DATE('03/31/2010 19:10:33', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('04/01/2010 16:17:40', 'MM/DD/YYYY HH24:MI:SS'), 10077, 
        NULL, 'CS009', NULL, TO_DATE('03/31/2010 19:10:33', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('03/31/2010 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), 
        'A', TO_DATE('03/31/2010 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('03/31/2010 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), 'NAC', 'CA  ', 
        'GSM', 581751708, 24798333, NULL, NULL, 
        TO_DATE('03/31/2010 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('09/29/2010 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), NULL, 6, NULL, 
        NULL, 12093584, '2357 ', '2357 ', 'DFLT ', 
        'DFLT ', NULL, '045', 'S', NULL, 
        NULL, NULL, NULL, NULL, NULL, 
        NULL, NULL, TO_DATE('03/31/2010 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), NULL, TO_DATE('03/31/2010 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), 
        'TEMO', NULL, NULL, NULL, NULL, 
        'TEL', NULL, TO_DATE('12/31/4700 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), 'N', 'N', 
        'Y', NULL, NULL, NULL, NULL, 
        NULL, NULL, NULL, NULL, NULL, 
        NULL, NULL, 9474437, 'DK', '01', 
        NULL, 'N', NULL, 999999999.99, '12', 
        NULL, NULL, NULL, NULL, NULL, 
        NULL, NULL, NULL, NULL, NULL, 
        NULL, NULL, NULL, NULL);
    Insert into SUBSCRIBER
       (SUBSCRIBER_NO, CUSTOMER_ID, SYS_CREATION_DATE, SYS_UPDATE_DATE, OPERATOR_ID, APPLICATION_ID, DL_SERVICE_CODE, DL_UPDATE_STAMP, EFFECTIVE_DATE, INIT_ACTIVATION_DATE, SUB_STATUS, SUB_STATUS_DATE, ORIGINAL_INIT_DATE, SUB_STATUS_LAST_ACT, SUB_STATUS_RSN_CODE, PRODUCT_TYPE, CUSTOMER_BAN, CTN_SEQ_NO, REQ_ST_GRACE_PERIOD, REQ_END_GRACE_PERIOD, COMMIT_START_DATE, COMMIT_END_DATE, COMMIT_REASON_CODE, COMMIT_ORIG_NO_MONTH, SUSP_RC_RATE_TYPE, CONTRACT_NO, CNT_SEQ_NO, DEALER_CODE, ORG_DEALER_CODE, SALES_AGENT, ORG_SALES_AGENT, REQ_DEPOSIT_AMT, LEADING_NUMBER, PABX_IND, NEXT_CTN, NEXT_CTN_CHG_DATE, PRV_CTN, PRV_CTN_CHG_DATE, NEXT_BAN, NEXT_BAN_MOVE_DATE, PRV_BAN, PRV_BAN_MOVE_DATE, SUB_STS_ISSUE_DATE, ACTIVATE_WAIVE_RSN, EARLIEST_ACTV_DATE, SUB_ACTV_LOCATION, CUST_WATCH_LMT, CUST_WATCH_DATE, BASIC_WATCH_LMT, CREDIT_WATCH_PIN_CD, SUB_MARKET_CODE, LIMIT_RESERVED_DAYS, FF_EXPIRATION_DATE, FLEX_IND, DUO_IND, LISTED_IND, SUB_DEPARTMENT_CD, LAST_SUBS_DISC_DT, LAST_SUBS_DISC_DT_UD, LAST_SUBSCR_DISC_SN, LAST_SUBSCR_DISC_SN_UD, PNI, RMS_REF_STORE_ID, RMS_REF_TYPE, RMS_REF_OD, DLR_ACT_FEE, PREP_AMOUNT, SUBSCRIBER_ID, SUB_LANG, SMS_RCV_STYLE_CODE, CONV_RUN_NO, ALLOW_ADVERTISING_IND, IVR_WRONG_ACCESS_NO, THRESHOLD_AMT, PUBLISH_LEVEL, AUTO_RELEASE_IND, CUST_WATCH_EFF_DATE, CUST_WATCH_EXP_DATE, OPERATOR_CW_LMT, SEND_SMS_FOR_MATCH, CPS_STATUS, CPS_TRANSACTION, CPS_TYPE, ISP_PASS, ISP_TYPE, OPERATOR_TMP_DATE, OPERATOR_TMP_LMT, SUB_ORG_CD, ORG_MEMBER_NO)
     Values
       ('GSM04528890298', 816370100, TO_DATE('09/03/2005 10:12:13', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('03/14/2006 12:20:09', 'MM/DD/YYYY HH24:MI:SS'), 14462, 
        NULL, 'CS016', NULL, TO_DATE('03/14/2006 12:20:08', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('09/03/2005 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), 
        'C', TO_DATE('03/14/2006 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('09/03/2005 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), 'CAN', 'CNP3', 
        'GSM', 816370100, 12575966, NULL, NULL, 
        TO_DATE('09/03/2005 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('03/02/2006 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), 'PPD', 6, NULL, 
        '690925', 3436964, '4243 ', '4243 ', 'DFLT ', 
        'DFLT ', NULL, '045', 'S', NULL, 
        NULL, NULL, NULL, NULL, NULL, 
        NULL, NULL, TO_DATE('03/14/2006 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), NULL, TO_DATE('09/03/2005 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), 
        'TEMO', NULL, NULL, NULL, NULL, 
        'TEL', NULL, NULL, 'N', 'N', 
        'Y', NULL, NULL, NULL, NULL, 
        NULL, NULL, NULL, NULL, NULL, 
        NULL, NULL, 1436383, 'DK', '01', 
        NULL, 'N', NULL, 9999999.99, '0', 
        NULL, NULL, NULL, NULL, NULL, 
        NULL, NULL, NULL, NULL, NULL, 
        NULL, NULL, NULL, NULL);

    Hello

    Welcome to the froum!

    Thanks for posting the CREATE TABLE and INSERT! It's very nigra.

    user12990691 wrote:
    ...
    logon_histories_r table records the information of each user who connects to the system. Subscriber Details table contains all the information corresponding to subscriber_no, only 1 row should be returned.

    Do you mean a line by the user, or a line every time that you run the report, regardless of the number of users connected during the period that interests us?
    Anyway, if there are multiple logons, how do you decide that one? Or the output of logon_histories_r columns will be a sort of composite?

    I'm confused usage date condition for the table of the Subscriber, the input parameter date 04/04/2006 to 15/04/06

    Select lh.logon_id, lh.user_id, lh.logon_time, lh.logon_type, subs.subscriber_no, subs.customer_id
    of logon_histories_r lh, subscribed subs
    where lh.logon_time > = to_date('05-04-2010','dd-mm-yyyy')--to_date('04-04-2006','dd-mm-yyyy')
    and lh.logon_time< to_date('06-04-2010','dd-mm-yyyy')="" --="">
    and lh.user_id = substr (subs.subscriber_no,-10);

    Must LH.LOGON_TIME match something in the subscruber table? If so, you need to addsome extra join pathological.
    For example, if lh.logon_time must be between d1 and d2 (where d1 and d2 are DATE columns), then:

    select      lh.logon_id
    ,     lh.user_id
    ,     lh.logon_time
    ,     lh.logon_type
    ,     subs.subscriber_no
    ,     subs.customer_id
    from      logon_histories_r      lh
    ,      subscriber           subs
    where      lh.logon_time      >= to_date ('05-04-2010','dd-mm-yyyy') -- to_date('04-04-2006','dd-mm-yyyy')
    and      lh.logon_time      <  to_date ('06-04-2010','dd-mm-yyyy') -- to_date('15-01-2007','dd-mm-yyyy')
    and      lh.user_id      = substr (subs.subscriber_no, -10)
    and     lh.logon_time     >= subs.d1     -- New condition added
    and     lh.logon_time     <= subs.d2     -- New condition added
    ;
    

    Please find DDL and data relevant to these results. There are millions of records of Subscriber & logon_histories_r table, I am given appropriate providing a subscriber_id.

    That's smart, don't not post each row of the table: looks like you posted just enough to show what the problem is.
    Try to do the same thing with the columns. Do not post every single column, just the columns that have something to do with the problem.

  • Help in mandatory query - pulling data from two tables and inserting a

    Hi all

    I need your help for the modification of the query to get the desired result.
    I have two tables A and b. using source Insert and select the command, I need to extract data from tables A and B, then insert and C.
    Data and table structures are available below.

    Table (Source Table)

    Status of payment $
    MUL DC 20
    ONLY DC 20
    ONLY 40 PA
    MUL NY 50

    Table B (Source Table)

    State of lang units
    E DC 10
    S DC 10
    NY E 5
    PA S 5

    Based on query, I need the values in table C as mentioned below.
    Table C (Table of Destination) (necessary output query must also be as below)

    The State value

    PA 8
    DC 1

    My query is

    INSERT INTO C(STATE,VALUE)
    SELECT A.STATE, SUM ($) /SUM (UNITS)
    OF A, B
    WHERE PAYMENT = "SINGLE".
    AND A.STATE = B.STATE
    GROUP OF A.STATE, B.STATE

    But the output I get is

    PA 8
    DC 2

    Essentially to DC, I should get 1, i.e., for payment only $ DC is 20 and divided by 20 DC must be 1.
    Let me know where I'm missing.

    Hello

    It will work you need to add units in the group by clause

    SELECT a.state, SUM (dollars) / units
    FROM a, (SELECT state, SUM (units) units
             FROM b
             GROUP BY state) sub
    WHERE payment = 'SINGLE' AND a.state = sub.state
    GROUP BY a.state, units;
    

    Concerning

  • SELECT from two tables

    Hello, I have a problem writing to a specific SELECT statement and I hope you can help me.

    I have two tables:

    Customer:

    -Integer ID (PK)
    -Name_SecondName varchar (20)
    -Char sex
    -Full scale

    Investments:

    -Integer ID (PK)
    -Whole amount
    -Interest Numeric (3.2)
    -Client_ID (FK)


    My job is to display a number of men and a few women who have at least a $ 1000 investment. I'll jump to add data to the table, my point is simply to find a correct interpretation of the SQL query. Right now I have this:

    SELECT COUNT (DISTINCT Client_ID), COUNT (DISTINCT Client_ID)
    SOME customers JOIN investments
    WE Clients.ID = Investments.Client_ID
    WHERE amount > 1000;

    Of course, it displays twice the number of clients thanks to an investment of more than $ 1000. But how do I specify that the first indictment counts men (sex = am') and second - women (sex = 'F')? Can someone help me?

    Published by: 934019 2012-05-13 12:10

    Hello

    Here's a way to do

    SELECT       COUNT (DISTINCT CASE WHEN c.gender = 'M' THEN c.client_id END)     AS men
    ,       COUNT (DISTINCT CASE WHEN c.gender = 'F' THEN c.client_id END)     AS women
    FROM       clients       c
    JOIN       investments       i  ON       c.client_id  = i.client_id
    WHERE       i.amount       >= 1000
    ;
    

    This query will work in Oracle 8.1 or more.
    Since you have Oracle 11, you can also use the SELECT... Function pivot, but in this case, it's more complicated. That's because what to CHOOSE... PIVOT includes automatically by each column that is not involved in the pivot. (In this case, this means that all except sex and client_id columns.) Often, you do sort of a subquery to get the dynamic no cross data, so it is easy to include only the relevant columns. In this case, however, you need not any kind of subquery, so you should add a fair to exclude the additional columns if you want to use SELECT... PIVOT.

    As you say in your original post, this account of customers who have any single investment of 1000 or more. In your last post, you posted a query that looks for investments of more than 15,000. You can change the WHERE clause to say

    WHERE       i.amount       >  15000
    

    but which would produce 0 men and 0 women, given that all of the amounts in the sample data are 10000.

    934019 wrote:
    Is it possible to display the entire word 'Genre' and not only "G"?

    Sure.

    SQL * automatically sizes string columns to their maximum size. Since between the sexes are defined as CHAR (1), its maximum size is 1 character, then SQL * Plus allocates only 1 space for her, truncate the heading after 1 character. You can explicitly set the width on anything it is large enough to show the entire title, like this:

    COLUMN  gender  FORMAT  A6
    

    Include this command before you run the query. Then, SQL * Plus uses 6 places to display the sex, so there will be place for all 6 characters in the heading.

  • help in registration of the records from two tables

    HI: I have two tables joined the first field. The field is the primary key in the first table. Need help listing records from both tables with each a line/record results.
    create table EVENTS (
    event_key varchar2(64) primary key,
    event_description varchar2(64),
    create_time int
    );
    
    
    create table EVENT_UPDATES (
    event_key varchar2(64) NOT NULL ,
    update_description varchar2(64),
    update_time int
    );
    
    
    insert into EVENTS values('Event1', 'This is event1', 1);
    insert into EVENT_UPDATES values('Event1', 'Ticket created', 3);
    insert into EVENT_UPDATES values('Event1', 'Event cleared', 10);
    insert into EVENTS values('Event2', 'This is event2', 4);
    insert into EVENT_UPDATES values('Event2', 'Ticket created', 6);
    insert into EVENT_UPDATES values('Event2', 'Event cleared', 8);
    I want to print each record in the table of EVENTS such as a line and the corresponding records in EVENT_UPDATES as a line like this record
    Event1   1     This is event1
                3     Ticket created
                10   Event cleared
    Event2   4     This is event2
                6     Ticket created
                8     Event cleared
    TIA
    Ravi
    select  case weight
              when 1 then event_key
            end key,
            time_val,
            description
      from  (
              select  event_key,
                      create_time time_val,
                      event_description description,
                      1 weight
                from  events
             union all
              select  event_key,
                      update_time,
                      update_description,
                      2 weight
                from  event_updates
            )
      order by event_key,
               weight
    /
    
    KEY          TIME_VAL DESCRIPTION
    ---------- ---------- -------------------------
    Event1              1 This is event1
                        3 Ticket created
                       10 Event cleared
    Event2              4 This is event2
                        6 Ticket created
                        8 Event cleared
    
    6 rows selected.
    
    SQL> 
    

    SY.

  • delete rows from two tables

    Hello

    My main table is:

    create table CvProperties(
    cv_id number(14) primary key,
    user_id number(14) constraint Cv_fk1 references users(user_id),
    cat_id number(14) constraint Cv_fk2 references CvCategories(cat_id),
    employerOrAgent_id number(14) constraint Cv_fk3 references employerOrAgent(employerOrAgent_id),
    staff_id number(14) constraint Cv_fk4 references staff(staff_id),
    cvDate timestamp(0) default sysdate,
    cvName varchar2(230),
    status number(3),
    prev_cvId number(14),
    isEdited number(2),
    cvSource number(2) /**website, employer, agent, staff**/
    );
    

    Detail table is:

    create table cvDetails(
    cd_id number(14) primary key,
    cv_id number(14) constraint education_fk references CvProperties(cv_id),
    nationality varchar2(230),
    objectives varchar2(3900),
    name varchar2(230),
    fatherName varchar2(230),
    motherName varchar2(230),
    dob varchar2(230).
    gender varchar2(230),
    mStatus varchar2(230),
    passportNo varchar2(110),
    email varchar2(230),
    phone varchar2(45),
    mobile varchar2(25),
    address varchar2(2500),
    state varchar2(230),
    zipCode varchar2(230),
    city varchar2(230),
    education clob,
    experience clob,
    skills clob,
    languages varchar2(1400),
    hobbies varchar2(3200),
    achievements varchar2(3900),
    references varchar2(3900));
    

    I'm trying to delete the cvs that have no email + mobile + phone:

    select COUNT(*) from cvDetails where email is NULL AND mobile IS NULL AND phone IS NULL;
    

    This query shows 4814 CVs.

    How can I run that check if the e-mail, phone mobile, is null then remove cv of the two tables in query?

    Please notify

    https://www.Google.com/webhp?hl=en&tab=WW#hl=en&q=Oracle+on+delete+cascade

  • Delete rows in a table when the columns from two tables match

    Hello

    I have following two tables.

    ===========================================

    create the table empbooth as

    (

    Select 1 empid, 1 double cabin Union all the

    Select option 2, Union 1 double all the

    Select 3, Union 1 double all the

    Select option 4, Union 2 double all the

    Select option 5, 2 double

    );

    create the table attsht as

    (

    Select 1 empid, 240 reg, 0 unpaid all double union

    Select option 2, reg 200, 0 unpaid of all the double union

    Select 3, 240 reg, 0 unpaid all double them union

    Select 4 480 reg, 0 unpaid all double union

    Select 5 240 reg, unpaid double 0

    );

    =================================================

    I want to remove rows from attsht where corresponding booth (which is stored in the empbooth table) is 1.

    The condition is 'where attsht.empid = empbooth.empid and empbooth.booth = 1 '.

    I use oracle 10g.

    Help, please

    delete from attsht where a.empid in (select b.empid from empbooth b where b.booth = 1)

    or

    remove from attsht a

    where exists (select null

    of empbooth b

    where b.booth = 1

    and b.empid = a.empid)

  • How to match columns from two tables with

    Hello:
    I have two tables as below:

    Table1::(Base Table)
    Country | Prefix | Prefix_Length
    Travel | 001 | 3
    CountryB. 0012 | 4
    PaysC | 00443 | 5
    CountryD | 0091 | 4

    :(Detail Table) table2
    The population | Area | Prefix
    500 | AreaA | 0015921
    1000 | AreaB | 00122
    400. AreaC. 00443743
    300. ALIS | 0091333
    100. AreaA | 001

    I need to match these two tables with prefix columns (whose length is not fixed in the two tables: but it starts with 00 in the two tables). Two different countries the prefix may be similar up to a certain length. Thus, Prefix_Length can be used to determine (exactly) how much time should be taken in the search of Table2.

    Output:
    Country | Prefix | Area | Population
    Travel | 001 | AreaA | 600
    CountryB. 0012 | AreaB | 1000
    PaysC | 00443 | AreaC. 400
    CountryD | 0091 | ALIS | 300

    Please help me with your valuable comments.

    -Tender

    Try this

    with base_table as (
                        select 'CountryA' country,'001' prefix,3 prefix_length from dual union all
                        select 'CountryB','0012',4 from dual union all
                        select 'CountryC','00443',5 from dual union all
                        select 'CountryD','0091',4 from dual
                       ),
       detail_table as (
                        select 10 no_of_call,'0015921' prefix from dual union all
                        select 3,'00122' from dual union all
                        select 50,'00443743' from dual union all
                      select 50,'00443643' from dual union all
                        select 300,'0091333' from dual union all
                        select 60,'001' from dual
                       ) 
    
    SELECT  country,
            prefix,sum(no_of_call)
       FROM (
             select  country,
            b.prefix,no_of_call,
            decode(no_of_call,lead(no_of_call,1,0) over(partition by no_of_call order by b.prefix,no_of_call),'y','n') y_or_no
      from  base_table b,
            detail_table d
      where b.prefix = substr(d.prefix,1,prefix_length))
      where y_or_no !='y'
      group by  country,
            prefix
      order by country,
            prefix;
    

    Published by: Vi on 20 February 2012 01:07

  • Find unmatched columns from two tables

    Hello guys,.

    I am trying to compare two tables based on a key of the indexed columns.

    Here is an example of what I'm trying to achieve:

    Table A: A_ID A_Name A_Income A_housecount
    Jess 11 9 2
    Rauny 4 6 22

    Table b: B_ID B_Income B_housecount
    11-5-2
    22 6 4
    In the example above data columns A_ID and B_Id are same in both tables. I'm trying to compare A_Income with B_Income & & A_housecount with B_housecount. The results of this series of samples would be:

    11-9-2
    11-5-2

    as income in the same id is different.

    As I have large amount of data in the two tables can you please give me some ideas on how I can get my results? Let me know if the explanation is not clear for you.

    Thanks in advance
    select hshold_id,hsold_income,hshold_size,
           'abc.' || case count(src1) when 0 then 'demo' else 'hshold' end the_source
      from (select hshold_id,hsold_income,hshold_size,
                   1 src1,
                   to_number(null) src2
              from abc.hshold
            union all
            select hshold_id,hsold_income,hshold_size,
                   to_number(null) src1,
                   2 src2
              from abc.demo
           )
     group by hshold_id,hsold_income,hshold_size
     having count(src1) != count(src2)
    

    Concerning

    Etbin

    Edited by: Etbin on 11.2.2011 18:00
    correction of alignment

  • How to migrate from two tables

    Hello

    I have three tables.
    Issue table 1)
    QID text
    1. What is the capital of the India?
    2 who is our PM?

    (2) table answer
    response to help qid
    1 1 Chennai
    2 1 Delhi
    3 1 Bangulore
    4 2 kamal Singh
    5 2 Sonia
    6 2 Manmohan Singh

    (3) table c
    question A B C qid
    1. What is the capital of the India? Bangulore of Delhi from Chennai
    2 who is our PM? Kamal Singh Sonia Manmohan Singh

    Please tell me how to insert data from the first two tables in the third table by using a procedure?
    I tried, I get answers in the columns...

    Thank you
    SAI

    Look at this post.

    (1) I used row_number to retrieve the columns, for which the data are intended
    (2) I used the PIVOT to convert data into columns.

    Re: How to migrate two tables

  • Creating records from two Tables at the same time...

    I would be very grateful if someone could help with the following query.

    I have two Tables, Tbl1 and Tbl2. Tbl1 has the following columns: -.

    Tbl1_Unique_ID, Description

    Tbl1_Unique_ID is of type ' * number *' and ' * PK * ', Description is of type' * Varchar2 *'.

    Tbl2 has the following columns: -.

    Tbl2_Unique_ID, Description, Tbl1_Unique_ID

    Tbl2_Unique_ID is of type ' * number *' and is the ' * PK * ', Description is of type' * Varchar2 *' and Tbl1_Unique_ID is of type ' * number *', is a ' * foreign key *' and is the ' * primary key *' from Tbl1.

    While I can create a page to display and create folders in Tbl1, I'm not course coding required to view and create records Tbl1 and Tbl2 simultaneously, as well as regarding the two together at the same time.

    I know that it involves one ' * INSERT *' statement, but I have problems the correct SQL query.

    Can anyone provide any assistance will be appreciated.

    Have you tried to create a form master / detail page? Because it seems that is what you need...

  • Combine multiple lines into one line (from two tables / result sets)

    Hello experts,

    I would like to know how to combine multiple lines/records in a single record. Here are the DDL and DML to tables:

    create table test_table)

    client_name varchar2 (50 char),

    login_time timestamp (6).

    logout_time timestamp (6).

    auto_type varchar2 (10 char)

    )

    create table root_table)

    navigation_time timestamp (6).

    client_name varchar2 (50 char),

    VARCHAR2 (50 char) nom_du_groupe

    )

    Insert into test_table

    values ("John", TO_TIMESTAMP ('2013-12-05 17:04:01.512 ',' YYYY-MM-DD HH24:MI:SS.)) FF'), TO_TIMESTAMP ('2013-12-05 17:27:31.308 ',' YYYY-MM-DD HH24:MI:SS.) FF'), 'SIMPLE');

    Insert into test_table

    values ('David', TO_TIMESTAMP ('2013-12-05 06:33:01.308 ',' YYYY-MM-DD HH24:MI:SS.)) FF'), TO_TIMESTAMP ('2013-12-05 06:45:01.112 ',' YYYY-MM-DD HH24:MI:SS.) FF'), 'SIMPLE');

    insert into root_table

    values (TO_TIMESTAMP ('2013-12-05 17:04:01.512 ',' YYYY-MM-DD HH24:MI:SS.)) FF'), 'John', "invalid");

    insert into root_table

    values (TO_TIMESTAMP ('2013-12-05 17:14:22.333 ',' YYYY-MM-DD HH24:MI:SS.)) FF'), 'John', "GROUP_1");

    insert into root_table

    values (TO_TIMESTAMP ('2013-12-05 17:27:31.308 ',' YYYY-MM-DD HH24:MI:SS.)) FF'), 'John', "GROUP_1");

    insert into root_table

    values (TO_TIMESTAMP ('2013-12-05 06:33:01.308 ',' YYYY-MM-DD HH24:MI:SS.)) FF'), "David", "invalid");

    insert into root_table

    values (TO_TIMESTAMP ('2013-12-05 06:45:01.112 ',' YYYY-MM-DD HH24:MI:SS.)) FF'), 'David', 'GROUP_5');

    game results test_table

    client_name

    login_time logout_time auto_typeJohn05/12/2013 5:04:01.512000 PM05/12/2013 5:27:31.308000 PMSIMPLEDavid05/12/2013 6:33:01.308000 AM05/12/2013 6:45:01.112000 AMSIMPLE

    root_table result set

    navigation_time client_name GroupName
    05/12/2013 5:04:01.512000 PMJohnNot valid
    05/12/2013 5:14:22.333000 PMJohnGROUP_1
    05/12/2013 5:27:31.308000 PMJohnGROUP_1
    05/12/2013 6:33:01.308000 AMDavidNot valid
    05/12/2013 6:45:01.112000 AMDavidGROUP_5

    And here is the SQL code I'm writing:

    Select a.customer_name, a.login_time, a.logout_time, a.auto_type, Max (b.group_name)

    from test_table a, b root_table

    where a.customer_name = b.customer_name

    Group of a.customer_name, a.login_time, a.logout_time, a.auto_type

    As the 'invalid' value is greater than the value "GROUP_1" (based on the number of letter in English), the GroupName is returned as 'invalid '. I want to bring the GroupName based on the navigation_time column in the root_table so that it always returns a valid GroupName. Please help me.

    Output current:

    Client_name.      Login_Time.     Logout_Time |     Auto_Type |     GroupName

    --------------------------------------------------------------------------------------------------------------------------------------------

    John |     05/12/2013 5:04:01.512000 PM |     05/12/2013 5:27:31.308000 PM |     SIMPLE |     Not valid

    David |     05/12/2013 6:33:01.308000 AM |     05/12/2013 6:45:01.112000 AM |     SIMPLE |     Not valid

    Expected results:

    Client_name.      Login_Time.     Logout_Time |     Auto_Type |     GroupName

    --------------------------------------------------------------------------------------------------------------------------------------------

    John |     05/12/2013 5:04:01.512000 PM |     05/12/2013 5:27:31.308000 PM |     SIMPLE |     GROUP_1

    David |     05/12/2013 6:33:01.308000 AM |     05/12/2013 6:45:01.112000 AM |     SIMPLE |     GROUP_5

    Thank you!

    Adding INSERT statements, current and planned outputs.

    This...

    SELECT client_name

    login_time,

    logout_time,

    auto_type,

    GroupName

    Of

    (select a.customer_name,

    a.login_time,

    a.logout_time,

    a.auto_type,

    b.group_name,

    ROW_NUMBER() over (PARTITION BY a.customer_name, a.login_time, a.logout_time, a.auto_type ORDER BY b.group_name) rn

    from test_table a, b root_table

    where a.customer_name = b.customer_name)

    WHERE rn = 1;

    OUTPUT:-

    =========

    David DECEMBER 5, 13 06.33.01.308000000 AM DECEMBER 5, 13 06.45.01.112000000 AM SIMPLE GROUP_5
    John DECEMBER 5, 13 05.04.01.512000000 PM DECEMBER 5, 13 05.27.31.308000000 PM SIMPLE GROUP_1

    Thank you

    Ann

Maybe you are looking for

  • Working with HDV images?

    Got a project shot in HDV. Finally, I would like to put out as ProRes 422 progressive, not interlaced. I wonder if I could take the HDV project and... instead of make files Proxy, make "optimized" ProRes 422 (or light in this case ProRes) files.  And

  • CD burning problems

    I have a Dell Inspiron 1525 with Windows Vista Home Premium.  Lately I had problems with CD burning.  If the CD or DVD already has data on it, it burns very well.  But, if I put a blank CD or DVD in the drive, my computer does not even recognize that

  • JDE dosen't start more

    Hi people, I developed my application on JDE 6.4.1. A few days ago I have installed all the other JDE to test the object. Now, I can not start any JDE. I uninstalled all d and again installed the JDE 4.6.1. But it begins only once the reinstallation.

  • Installation of Signature keys

    I had three files for signature keys, that I applied.  I followed the instructions; below but I can never get to step 8.  After step 7, a dialog box opens for what .cod of opening?  Clues? BlackBerry JDE plugin for Eclipse users: (1) save all 3 .csi

  • Two VWIC3-2MFT won't wake up 2921 router

    My 2921 Cisco is comes with two pre-installed VWIC3-2MFT-T1/E1, and I had no problem adding as a gateway for my new BE6000 version 9.1 CUCM MGCP. However, even if the two VWIC3 appear to the living room of the inventory, they seem quite dead. All LED