I have two tables display

I have two table display and it works very well, but I want to display the data as all first it display data from a table in ascending order, then
It show data from the second table in the order of asceding

create or replace view wg_team
as
Select emp_name form wgteam
Union
Select the name of the component in component_master;

create or replace view wg_team
as
Select emp_name, 1 test for form wgteam
Union
Select the name of the component, 2 test of component_master
order of test;

Tags: Database

Similar Questions

  • It is possible to have two tables with the same name in Oracle!

    Oracle Version: 10 gr 2

    MS Access 2007, I had to use the 'Export' by which I copy a table (and its data) to an Oracle schema via an ODBC connection. Later, I realized that, during the copy of tables with a mix of lower and upper case names, the table does not copied (exported). But MS Access will give you the message that table obtained export successfully.

    MS-Access mess around Oracle data dictionary.

    When you issue
    SQL>select * from tab;
    
    TNAME                          TABTYPE  CLUSTERID
    ------------------------------ ------- ----------
    AMStates                       TABLE
    Version                        TABLE
    You will see the names of the tables. But when you try to DESCRIBE or SELECT this table, you will
    SQL>desc Version
    ERROR:
    ORA-04043: object Version does not exist
    You can even create another table with the same name in the schema
    SQL>create table VERSION (X NUMBER);
    
    Table created.
    Why this is happening and how can I bring these items 'non-existent '?

    Hello

    Use

    SQL > desc 'Version '.

    Or

    SQL > select * from 'Version '.

    Or

    SQL > drop table 'Version '.

    To overcome the problems of mixed-case.

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

  • How to join two tables if you transpose the rows, columns and rows in one of the table

    Hi guys,.

    can someone help me please in the write request

    I have two tables

    Agents and Agent phones but in the agent phones table for the id of an agent it displays 4 rows because one of the column there types of different phones (office, mobile, home, fax)

    So instead of display 4 rows, I used max(case...) to convert rows to columns

    now how to reach it with another table

    Requirement:

    Database: 11.2.0.2.0

    create the table AGENT_PHONE

    (

    agent_id NUMBER (20) not null,

    agent_type_code VARCHAR2 (10) not null,

    agent_type_prefix VARCHAR2 (10) not null,

    Phone_Number VARCHAR2 (16) not null,

    phone_type_code VARCHAR2 (10) not null

    )

    CREATE TABLEAGENTS

    (

    agent_id NUMBER (20) not null,

    agent_type_code VARCHAR2 (10) not null,

    agent_type_prefix VARCHAR2 (10) not null,

    NAME VARCHAR2 (40) NOT NULL

    )

    INSERT INTO AGENT_PHONE(AGENT_ID,AGENT_TYPE_CODE,AGENT_TYPE_PREFIX,PHONE_NUMBER,PHONE_TYPE_CODE)

    VALUES (29709, ARE ', 'OFFICE', '4805551436', 'CELL');

    INSERT INTO AGENT_PHONE(AGENT_ID,AGENT_TYPE_CODE,AGENT_TYPE_PREFIX,PHONE_NUMBER,PHONE_TYPE_CODE)

    VALUES (29709, ARE ', 'OFFICE', '1111111111', 'PHONE');

    INSERT INTO AGENT_PHONE(AGENT_ID,AGENT_TYPE_CODE,AGENT_TYPE_PREFIX,PHONE_NUMBER,PHONE_TYPE_CODE)

    VALUES (29709, ARE ', 'OFFICE', '2223334444',' OFF');

    INSERT INTO AGENT_PHONE(AGENT_ID,AGENT_TYPE_CODE,AGENT_TYPE_PREFIX,PHONE_NUMBER,PHONE_TYPE_CODE)

    VALUES (29709, ARE ', 'OFFICE', '5556667788', 'FAX');

    INSERT INTO VALUES AGENTS

    (29709, ARE ', 'OFFICE', 'FLY');

    INSERT INTO VALUES AGENTS

    (1234, ARE ', 'OFFICE', 'MIKE');

    SELECT * FROM AGENT_PHONES

    AGENT_IDAGENT_TYPE_CODEAGENT_TYPE_PREFIXPHONE_NUMBERPHONE_TYPE_CODE

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

    29709REOFFICE4805551436CELL
    29709REOFFICE1111111111PHONE
    29709REOFFICE2223334444OFF
    29709REOFFICE5556667788

    FAX

    SELECT * AGENTS

    AGENT_IDAGENT_TYPE_CODEAGENT_TYPE_PREFIX

    NAME

    29709REOFFICEROB
    1234REOFFICE

    MIKE

    This is so the data we have in both table

    Now, I transposed rows to columns in the table of agent phones so I used the following query

    SELECT AP. AGENT_ID,. AGENT_TYPE_CODE,. AGENT_TYPE_PREFIX.

    MAX (CASE WHEN AP. PHONE_TYPE_CODE = 'CELL' THEN AP. PHONE_NUMBER END) AS CELL.

    MAX (CASE WHEN AP. PHONE_TYPE_CODE = 'OFF' THEN AP PHONE_NUMBER END) AS TURNED OFF.

    MAX (CASE WHEN AP. PHONE_TYPE_CODE = 'FAX' THEN AP. PHONE_NUMBER END) LIKE FAX,.

    MAX (CASE WHEN PHONE_TYPE_CODE = 'PHONE'. THEN AP PHONE_NUMBER END) AS PHONE

    AGENT_PHONE AP

    WHERE AP. AGENT_ID = 29709

    GROUP OF AP. AGENT_ID, AP. AGENT_TYPE_CODE, AP. AGENT_TYPE_PREFIX.

    AGENT_IDAGENT_TYPE_CODEAGENT_TYPE_PREFIXCELLOFFFAXPHONE
    129709REOFFICE4805551436222333444455566677881111111111

    My question is how this to join the agents table so that my output should be like this...

    I want to display all the results in the table of the Agent, even if they are not in the table of agent phones. As you can see there are other agent id 1234 is also populated

    AGENT_IDAGENT_TYPE_CODEAGENT_TYPE_PREFIXNAMEAGENT_IDAGENT_TYPE_CODEAGENT_TYPE_PREFIXCELLPHONEOFFFAX

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

    29709REOFFICEROB29709REOFFICE4805551436111111111122233344445556667788
    1234REOFFICEMIKE

    Currently, I run this query and I get the output as below

    SELECT *.

    AGENTS HAS

    LEFT OUTER JOIN AGENT_PHONE AP

    ON A.AGENT_ID = AP. AGENT_ID

    AND A.AGENT_TYPE_CODE = AGENT_TYPE_CODE.

    AND A.AGENT_TYPE_PREFIX = AGENT_TYPE_PREFIX.

    AGENT_IDAGENT_TYPE_CODEAGENT_TYPE_PREFIXNAMEAGENT_IDAGENT_TYPE_CODEAGENT_TYPE_PREFIXPHONE_NUMBERPHONE_TYPE_CODE
    129709REOFFICEROB29709REOFFICE4805551436CELL
    229709REOFFICEROB29709REOFFICE1111111111PHONE
    329709REOFFICEROB29709REOFFICE2223334444OFF
    429709REOFFICEROB29709REOFFICE5556667788FAX
    51234REOFFICEMIKE

    I want id 29709 agent in a line with 1234 agent also id to display

    You can rotate your phone number of agent in columns

    Select *.

    of AGENT_PHONE

    pivot)

    min (PHONE_NUMBER)

    for PHONE_TYPE_CODE in ('CELL' as a 'CELL', 'PHONE' like 'PHONE', 'OFF' in the 'OFF', 'FAX' as 'FAX')

    )

    AGENT_ID AGENT_TYPE_CODE AGENT_TYPE_PREFIX CELL PHONE OFF FAX
    29709 RE OFFICE 4805551436 1111111111 2223334444 5556667788

    Then you can join to view inline or CTE

    with AGENT_PHONE_PIVOT like)

    Select *.

    of AGENT_PHONE

    pivot)

    min (PHONE_NUMBER)

    for PHONE_TYPE_CODE in ('CELL' as a 'CELL', 'PHONE' like 'PHONE', 'OFF' in the 'OFF', 'FAX' as 'FAX')

    )

    )

    SELECT *.

    AGENTS HAS

    LEFT OUTER JOIN AGENT_PHONE_PIVOT AP

    ON A.AGENT_ID = AP. AGENT_ID

    AND A.AGENT_TYPE_CODE = AGENT_TYPE_CODE.

    AND A.AGENT_TYPE_PREFIX = AGENT_TYPE_PREFIX.

    AGENT_ID AGENT_TYPE_CODE AGENT_TYPE_PREFIX NAME AGENT_ID AGENT_TYPE_CODE AGENT_TYPE_PREFIX CELL PHONE OFF FAX
    29709 RE OFFICE ROB 29709 RE OFFICE 4805551436 1111111111 2223334444 5556667788
    1234 RE OFFICE MIKE - - - - - - -

    Is that what you're looking for?

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

  • Union two Tables

    Hello

    I have two tables with the same data structures and I want the two to the union. The problem I faced with union is the results are joined and it is difficult to distinguish which set of result belongs to which table:

    for example

    Select * from staff
    Union
    Select * from employees

    Jan - 06 Division
    Activity 10
    Company 4
    6 marketing
    Marketing 3
    5 finance
    Finance 2

    Is there a way to display the above results like

    Jan - 06 Division
    "Staff".
    Activity 10
    6 marketing
    5 finance
    "Outgoing".
    Company 4
    Marketing 3
    Finance 2

    The difference is there is a line break, showing the separation of staff and outgoing. Can anyone help?

    Thank you

    Does that help?

    select 'STAFF' TABLE_NAME, s.* from staff s
    union
    select 'EMPLOYEES' TABLE_NAME, e.* from employees e
    
  • 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...

  • Two external displays connected to my dock and my ThinkPad T450

    I have two external displays connected to my dock and my ThinkPad T450.
    Everything works fine, when suddenly the monitor LEN LT2223pwC (using DP cable) goes into energy saving mode during use and there is not up to come back/wake, only to turn it off and back on
    This Setup worked very well with my office. For some reason any the monitor does not receive the signal from the laptop / docking station.

    I got a new docking station and solved the problem. Thank you

  • 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

  • Attach the two tables

    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

  • graph drawn using two tables

    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.

  • Join two tables for desired out put

    Hello

    I have two tables with structures below:

    TAB1:

    LEAD_NUM (PRIMARY KEY), IMPERATIVE_1, IMPERATIVE_2, IMPERATIVE_3, IMPERATIVE_4

    LEAD_NUMIMPERATIVE_1IMPERATIVE_2IMPERATIVE_3IMPERATIVE_4
    34HVJCXMNULL VALUEDGHKKK

    TAB2:

    LEAD_NUM (FOREIGN KEY), ACCOUNT_NAME, FISCAL_YEAR

    LEAD_NUMACCOUNT_NAMEFISCAL_YEAR
    34HVJATT2010
    34HVJATT2011
    34HVJATT2012

    I need the output in the format below:

    ACCOUNT_NAMELEAD_NUMFISCAL_YEARIMPERATIVES
    ATT34HVJ2010CXM, DGH, KKK
    ATT34HVJ2011CXM, DGH, KKK
    ATT34HVJ2012CXM, DGH, KKK

    Can anyone help me please with the query?

    Thanks in advance:

    Arpit

    create table TAB1

    (

    Key elementary school/LEAD_NUM varchar2 (100)

    IMPERATIVE_1 varchar2 (100),

    IMPERATIVE_2 varchar2 (100),

    IMPERATIVE_3 varchar2 (100),

    IMPERATIVE_4 varchar2 (100)

    );

    insert into tab1 values ("34HVJ", "CXM", "NULL", "DGH" 'KKK');

    create table TAB2

    (

    LEAD_NUM varchar2 (100),

    Account_name varchar2 (100)

    NUMBER OF FISCAL_YEAR

    );

    ALTER TABLE TAB2

    ADD CONSTRAINT fk_PerOrders

    FOREIGN KEY (LEAD_NUM)

    TAB1 (LEAD_NUM) REFERENCES

    INSERT INTO VALUES TAB2 ('34HVJ', 'ATT', 2010);

    INSERT INTO VALUES TAB2 ('34HVJ', 'ATT', 2011);

    SELECT t2.account_name, t2.lead_num, t2.fiscal_year,

    RTRIM (TRIM (CASE WHEN t1.imperative_1 IS NULL or t1.imperative_1 = 'NULL' THEN "ELSE t1.imperative_1 |)) ',' END |

    CASE WHEN t1.imperative_2 IS NULL or t1.imperative_2 = 'NULL' THEN ' ELSE t1.imperative_2 | ',' END |

    CASE WHEN t1.imperative_3 IS NULL or t1.imperative_3 = 'NULL' THEN ' ELSE t1.imperative_3 | ',' END |

    CASE WHEN t1.imperative_4 IS NULL or t1.imperative_4 = 'NULL' THEN ' ELSE t1.imperative_4 | (',' END), ',') requirements

    OF tab1 t1, t2 tab2

    WHERE t1.lead_num = t2.lead_num

    ORDER BY t2.fiscal_year

    Answer: -.

  • Comparison between two tables

    Hello

    I have two tables USERS and LISTS:

    And I want that there is a comparison between these two tables executed when user table USERS connect to the application.

    They must compare the columns between the SEXES and AGE and if some users have the same attributes in its ranks as in a line in the table LISTS (here is unique each line) so that the user gets in his line in the column 'LIST_ID' the ID of the line with which attributes between GENDER and AGE.

    Example:

    USERS TABLE: exampleuser | Boby | McGrahem | Male | 18. -------

    LISTS OF TABLE: 28 | examplelist | Male | 18

    Once the Login of the user Boby gets in its ranks the ID = 28 because the SEX and AGE corresponds to the row of table LIST:

    Result:

    USERS TABLE: exampleuser | Boby | McGrahem | Male | 18. 28

    
    CREATE TABLE  "USERS" 
       (    "USERNAME" VARCHAR2(15) NOT NULL ENABLE, 
            "FORRNAME" VARCHAR2(15) NOT NULL ENABLE,                  
            "SURNAME" VARCHAR2(15) NOT NULL ENABLE, 
            "GENDER" VARCHAR2(10) NOT NULL ENABLE,   
            "AGE" NUMBER, 
            "LIST_ID" NUMBER, 
             CONSTRAINT " USERS_PK" PRIMARY KEY ("USERNAME")
      USING INDEX  ENABLE
    
    

    CREATE TABLE  "LISTS" 
       (    " LIST_ID" NUMBER NOT NULL ENABLE, 
            " LISTNAME" VARCHAR2(50) NOT NULL ENABLE, 
            "GENDER" VARCHAR2(10) NOT NULL ENABLE, 
            "AGE" VARCHAR2(3) NOT NULL ENABLE,  
             CONSTRAINT " LISTS_PK" PRIMARY KEY ("LIST_ID")
      USING INDEX  ENABLE
       
    

    I need help for coding this, if someone be so good.

    This is my essay:


    DECLARE  
        v_listid varchar2(100);   
        BEGIN  
          
        SELECT  LIST_ID into v_listgid
         FROM LISTS
         WHERE GENDER = (SELECT GENDER
                              FROM USERS 
                            WHERE UPPER(TRIM(USERNAME)) = UPPER(TRIM(:APP_USER)))
         AND AGE = (SELECT AGE
                              FROM USERS  
                            WHERE UPPER(TRIM(USERNAME)) = UPPER(TRIM(:APP_USER)));
    
         UPDATE USERS   
        SET LIST_ID =  v_listid   WHERE UPPER(TRIM(USERNAME)) = UPPER(TRIM(:APP_USER));  
      
        END;
    

    I'd like to REALLY shy away using the USER name as the primary key, because the fact that users can create duplicate user names... YOU should NEVER base a PK on the entry of user, the better to let the database create and maintain this element of date...

    FIX:

    UPDATE to users U

    SET List_Id = (SELECT List_Id OF lists L WHERE L.Gender = U.Gender and L.SOMENUMBER = U.SOMENUMBER) AND

    Upper (U.UserName) = UPPER(:APP_USER);

    Don't really want to cut the strings, Oracle which will do since they are of type varchar2 columns...

    Thank you

    Tony Miller
    Software LuvMuffin
    Ruckersville, WILL

  • How the sum of these two tables?

    Hello

    I have two tables

    DESC ACTIVITE_EXCEP_FAITE

    NUMBER OF FICHE_ID

    NUMBER OF SERVICES_ID

    NUMBER OF ACTIVITES_EXCEPTIONNELLES_ID

    NUMBER OF TIME

    NUMBER OF ACTIVITE_EXCEP_FAITE_ID

    DESC ACTIVITE_FAITE

    NUMBER OF FICHE_ID

    NUMBER OF ACTIVITES_ID

    NUMBER OF SECTEURS_ID

    LENGTH NUMBER (8.2)

    NUMBER OF ACTIVITE_FAITE_ID

    NUMBER OF TYPE_ACTIVITE_ID

    I want to add the column to the DURATION of the two tables when they get the same FICHE_ID. FICHE_ID is not a join field.

    I've tried this application, but it gives result when two recordings of the two table share the same number FICHE_ID.

    SELECT AF. FICHE_ID, SUM (NVL (AF. LENGTH, 0)) + SUM (NVL (AEF. LENGTH, 0))

    OF AF, ACTIVITE_EXCEP_FAITE AEF ACTIVITE_FAITE

    WHERE AF. FICHE_ID = AEF. FICHE_ID

    GROUP BY AF. FICHE_ID;

    Can you help me write this selection?

    Thank you very much for your help!

    Like this?

    select nvl(af.fiche_id, aef.fiche_id) fiche_id
         , sum(nvl(af.duree,0)) + sum(nvl(aef.duree,0)) duree
      from activite_faite af
      full join
           activite_excep_faite aef
        on af.fiche_id = aef.fiche_id
     group by nvl(af.fiche_id, aef.fiche_id);
    
  • 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?

Maybe you are looking for