Combine the two columns of the table

SELECT providerid, Sum OF appdev.usercounts
WHERE the counttime BETWEEN SYSDATE - 30/1440 AND SYSDATE-15/1440 GROUP BY ORDER BY providerid providerid

697 W
U 813
T 143
S 2

SELECT providerid, Sum OF appdev.usercounts
WHERE the counttime BETWEEN - 30/1440 AND (SYSDATE-1) - 15/1440 (SYSDATE-1) GROUP BY ORDER BY providerid providerid;

450 W
U 571
T 80
S 2

I want output like

W 697 450
U 813 571
143 80 T
2 2 S
Help, please

Thank you
Praveen

'COUNT', which is the actual column name? It could become very confusing.

Not tested for obvious reasons, but it should be close:

SELECT providerid
     , sum(
         case when counttime between sysdate - 30/1440 and sysdate - 15/1440 then count end
       ) as cnt1
     , sum(
         case when counttime between (sysdate-1) - 30/1440 and (sysdate-1) - 15/1440 then count end
       ) as cnt2
FROM appdev.usercounts
WHERE ( counttime between sysdate - 30/1440 and sysdate - 15/1440 )
   OR ( counttime between (sysdate-1) - 30/1440 and (sysdate-1) - 15/1440 )
GROUP BY providerid
ORDER BY providerid
;

Tags: Database

Similar Questions

  • Oracle how to multiply two columns of different tables and results

    Oracle how to multiply two columns of different tables and get the result in the third column?

    I want to multiply all the lines of the quantinty column in the table of quantity with the relevant lines of the table of prices price column and get the result of multiplying in the third column. What should I use procedure trigerr? OR IS IT POSSIBLE HOW TO DO IT PLEASE HELP :D

    Edited by: 994229 2013-03-15 12:44
    /* Formatted on 3/15/2013 3:51:08 PM (QP5 v5.185.11230.41888) */
    CREATE TABLE mytable1
    AS
       (SELECT 1 id, 5 VALUE FROM DUAL
        UNION ALL
        SELECT 2, 7 FROM DUAL
        UNION ALL
        SELECT 3, 8 FROM DUAL);
    
    CREATE TABLE mytable2
    AS
       (SELECT 1 id, 4 VALUE FROM DUAL
        UNION ALL
        SELECT 2, 12 FROM DUAL
        UNION ALL
        SELECT 10, 12 FROM DUAL);
    
      SELECT id,
             mytable1.VALUE,
             mytable2.VALUE,
             mytable1.VALUE * mytable2.VALUE product
        FROM mytable1 FULL OUTER JOIN mytable2 USING (id)
    ORDER BY id;
    
    ID     VALUE     VALUE_1     PRODUCT
    1     5     4     20
    2     7     12     84
    3     8
    10          12     
    
  • SELECT with the combination of two columns query

    I need the research to write a nested select statement that would achieve the following.
    Support I have a table as follows
    TestTable
    Name: Age: country
    Test1: 10: USA
    Test2: 11: us.
    Test3: 12: us.
    Test4: 11: Canada
    Test5: 12: Canada

    Now, I want to select in the table above gives the following information.
    Get all the names of people who do not belong to this combination (10:USA, 11:Canada, 12:Canada). The list can be huge.
    The result should be
    Test1:10:USA
    Test1:12:USA

    If it was a combination, I can write
    Select * from TestTable
    the age where <>10 and <>country Canada

    Also, I can also do
    Select * from TestTable
    the age where NOT IN (10,11) and country NOT IN (USA, COUNTRY)
    But I do have that he would give me a correct result.

    sush_msn wrote:
    Is there a way I can move the age and the country as a list on the query?

    You asked the right question.

    Three things you need to know:

    (1) your test data cover all combinations. This is the most comprehensive test data:

    create table test_table1 as
    WITH AGES AS (
      SELECT LEVEL+10 AGE FROM DUAL CONNECT BY LEVEL <= 3
    ), COUNTRIES AS (
      SELECT 'USA' COUNTRY FROM DUAL
      UNION ALL
      SELECT 'CANADA' COUNTRY FROM DUAL
    )
    SELECT 'Test' || ROWNUM NAME, AGE, COUNTRY FROM AGES, COUNTRIES;
    
    NAME                                                AGE COUNTRY
    -------------------------------------------- ---------- -------
    Test1                                                11 USA
    Test2                                                11 CANADA
    Test3                                                12 USA
    Test4                                                12 CANADA
    Test5                                                13 USA
    Test6                                                13 CANADA
    

    (2) now, here's the answer to your question. You can go back two or more values in an expression by putting parentheses around them.

    SELECT * FROM TEST_TABLE1
    WHERE (AGE, COUNTRY) NOT IN (
      (11, 'USA'),
      (12, 'CANADA')
    );
    
    NAME                                                AGE COUNTRY
    -------------------------------------------- ---------- -------
    Test2                                                11 CANADA
    Test3                                                12 USA
    Test5                                                13 USA
    Test6                                                13 CANADA
    

    That's what made the Etbin above, but he used a select instead of a list of values.

    (3) can AGE or COUNTRY ever be NULL? You want to return the records that have NULL values in them? If so, you must use NOT EXISTS instead of NO po WARNING: Etbin code needs a bit of change: "where (age, country) = (t.age, t.country)" should be "where (age, country) = ((t.age, t.country)) '. You must always additional brackets on the right side.

  • The combination of two columns in a single

    Hi guys,.

    Is it possible for a query to combine two columns into one? For example, lets say I have the following query:

    SELECT ID, FIRST_NAME, LAST_NAME
    EMPLOYEES

    I want the output to have two columns: one that contains the ID and the other containing name followed by a space followed by LAST_NAME. I know how to do this outside the query using coldfusion, but it save me a lot of work if there is some way that the query could do for me.

    Yes but the operand of concatenation varies somewhat from a database
    management system to the other.

    In Oracle, it would look this IIRC.

    SELECT ID, FIRST_NAME. ' ' || LAST_NAME AS FULL_NAME
    EMPLOYEES

  • Combine the table with the problem of the different priorities

    Hi all


    The Date of the trial as below
    CREATE TABLE XX_TABLE_A
    (XITEM VARCHAR2(10),
     FROM_DATE DATE,
     END_DATE DATE,
     MODE_VALUE VARCHAR2(10)
    );
    
    CREATE TABLE XX_TABLE_B
    (XITEM VARCHAR2(10),
     FROM_DATE DATE,
     END_DATE DATE,
     MODE_VALUE VARCHAR2(10)
    );
    
    CREATE TABLE XX_TABLE_C
    (XITEM VARCHAR2(10),
     FROM_DATE DATE,
     END_DATE DATE,
     MODE_VALUE VARCHAR2(10)
    );
    
    CREATE TABLE XX_TABLE_D
    (XITEM VARCHAR2(10),
     FROM_DATE DATE,
     END_DATE DATE,
     MODE_VALUE VARCHAR2(10)
    );
    
    insert into XX_TABLE_A
    (XITEM,FROM_DATE,END_DATE,MODE_VALUE)
    VALUES
    ('ITEMX',to_date('20110901','YYYYMMDD'),to_date('20111231','YYYYMMDD'),'MODE_A');
    
    insert into XX_TABLE_B
    (XITEM,FROM_DATE,END_DATE,MODE_VALUE)
    VALUES
    ('ITEMX',to_date('20110801','YYYYMMDD'),to_date('20111031','YYYYMMDD'),'MODE_B');
    
    insert into XX_TABLE_C
    (XITEM,FROM_DATE,END_DATE,MODE_VALUE)
    VALUES
    ('ITEMX',to_date('20120201','YYYYMMDD'),to_date('20120531','YYYYMMDD'),'MODE_C');
    
    insert into XX_TABLE_D
    (XITEM,FROM_DATE,END_DATE,MODE_VALUE)
    VALUES
    ('ITEMX',to_date('20110701','YYYYMMDD'),NULL,'MODE_D');
    We need to combine the information in these tables operation,
    priority XX_TABLE_A > XX_TABLE_B > XX_TABLE_C > XX_TABLE_D

    for example,.
    XX_TABLE_A (priority 1)
    ARTICLEX, 01/09/2011 ~ 31/12/2011, MODE_A

    XX_TABLE_B (priority 2)
    ARTICLEX, 01/08/2011 ~ 31/10/2011, MODE_B

    XX_TABLE_C (priority 3)
    ARTICLEX, 01/02/2012 ~ 31/05/2012, MODE_C

    XX_TABLE_D (priority 4)
    ARTICLEX, 01/07/2011 ~, MODE_D


    We combine the information of mode as below:

    ARTICLEX, 01/07/2011 ~ 31/07/2011, MODE_D
    ARTICLEX, 01/08/2011 ~ 31/08/2011, MODE_B
    ARTICLEX, 01/09/2011 ~ 31/12/2011, MODE_A
    ARTICLEX, 01/01/2012 ~ MODE_D 31/01/2012.
    ARTICLEX, 01/02/2012 ~ 31/05/2012, MODE_C
    ARTICLEX, 01/06/2012 ~, MODE_D
    Mode Setting:
    
                  |----------------------------|                                      A
           |---------------------|                                                    B
                                                       |-------------------------|    C                                                    
     |------------------------------------------------------------------------------- D
    7/1   8/1   9/1    10/1    11/1    12/1   1/1    2/1     3/1   4/1    5/1   6/1
    
    Result:
        D      B                A                  D                C              D
     |-----|------|----------------------------|-------|-------------------------|---
    We are trying to solve the problem using pl/sql(cursor, function,...etc), but there are performance problem with large data.

    It will be resolved by parsed SQL?

    Any suggestion will be appreciated.

    Thanks in advance,
    Zhxiang

    Something like...

    SQL> ed
    Wrote file afiedt.buf
    
      1  with all_data as (
      2    select * from xx_table_a union all
      3    select * from xx_table_b union all
      4    select * from xx_table_c union all
      5    select * from xx_table_d
      6    )
      7  --
      8      ,mnths as (select add_months(from_date,rn) as dt
      9                 from   (select min(from_date) as from_date from all_data)
     10                        cross join
     11                        (select rownum-1 rn from dual
     12                         connect by rownum <= (select months_between(max(end_date),min(from_date))+2 from all_data)
     13                        )
     14                )
     15  select row_number() over (order by dt) as rn
     16        ,to_char(dt,'fmmm/dd') as dt
     17        ,replace(coalesce(a.mode_value, b.mode_value, c.mode_value, d.mode_value),'MODE_') as mode_value
     18  from mnths
     19       left outer join xx_table_a a on (mnths.dt between a.from_date and nvl(a.end_date,mnths.dt))
     20       left outer join xx_table_b b on (mnths.dt between b.from_date and nvl(b.end_date,mnths.dt))
     21       left outer join xx_table_c c on (mnths.dt between c.from_date and nvl(c.end_date,mnths.dt))
     22*      left outer join xx_table_d d on (mnths.dt between d.from_date and nvl(d.end_date,mnths.dt))
    SQL> /
    
            RN DT    MODE_VALUE
    ---------- ----- ----------
             1 7/1   D
             2 8/1   B
             3 9/1   A
             4 10/1  A
             5 11/1  A
             6 12/1  A
             7 1/1   D
             8 2/1   C
             9 3/1   C
            10 4/1   C
            11 5/1   C
            12 6/1   D
    
    12 rows selected.
    
  • Input data match with two columns in a table

    Hello

    I want to find records where the input data (> 100 records) are adapted to the two columns of the table

    See below
    with t as
    (select 1 as id, 101 as num 'ram' that pat from dual
    Union
    Select 2 102, 'tom' from dual
    Union
    Select 1 103, 'tom1' from dual
    Union
    Select 2 101, 'tom2' from dual
    Union
    Select 2 104, 'tom3' from dual
    Union
    Select 1 105, 'tom1' from dual
    Union
    Select 2 105, 'tom1' from dual

    )
    Select * from t

    I want to find records from the 't' table where (id, num) will be (1 101, 2 102, 1, 105)

    Output must be

    ID num
    1 101
    2 102
    1 105
    select *
    from t
    where  (id, num) in (
              (1,101),
              (2,102),
              (1,105)
                 );
    

    Or store the input in a temporary table values and use IN

    select *
    from t
    where  (id, num) in (
              select col1,col2
                                    from your_temp_table
                 );
    

    Published by: JAC on 20 may 2013 14:55

  • Requirement of Beeping - how to get subtotals for each combination of 2 columns val

    Hi gurus, Experts and all,.

    Help me please with my reporting requirement, on how to code this in PIF. Thank you.

    Requirement: I need to get the subtotals for each value of the combination of two columns.

    Columns example: team group AMOUNT

    Sample column values: placed Team1 100
    Group b... Team2... 200

    GroupA - Team1 Subtotals = 500 (value of the sample only)
    GroupA - Team2 Subtotals = 400 (value of the sample only)
    Group b - Team1 Subtotals = 600 (value of the sample only)
    Group b - Team2 Subtotals = 200 (value of the sample only)

    GrandTotal = 1700

    Thank you.

    Jean Paul
    BEEP newbie

    Published by: user10955574 on October 28, 2010 05:40
    
     -  - 
    
    

    output for data

    GROUPA - TEAM1 - 200
    GROUPB - TEAM1 - 300
    GROUPC - TEAM2 - 400
    GROUPD - TEAM2 - 500
    GROUPA - TEAM3 - 600
    GROUPB - TEAM3 - 700
    GROUPC - TEAM4 - 800
    GROUPD - TEAM4 - 900
    GROUPA - TEAM5 - 1000
    
  • trigger to concatenate two fields in a table

    Hello

    I'm trying to concatenate two columns in a table and add to the third column in the same table, all the columns are
    numbers, I want to write a trigger that is after insertion to do this... does anyone know how its done...

    Thank you very much
    Jessica

    Hi, Jessica,.

    Welcome to the forum!

    Do you really need to store this concatenation? How you get these results in a normalized database is to store the numbers separately and comnbine them, when necessary, in the queries and reports. You can use a view to avoid repeating the same coiding over and over again.

    If you really want to store the value, use a trigger INSERT or UPDATE BEFORE , like this:

    CREATE OR REPLACE TRIGGER     table_x_biu
    BEFORE     INSERT OR UPDATE
    ON     table_x
    FOR EACH ROW
    BEGIN
         :NEW.column_3 := TO_CHAR (:NEW.column_1)
                    || '-'
                    || TO_CHAR (:NEW.column_2);
    END;
    

    I'm confused about your specific needs. Concatentaion is possible for strings.
    If colonne_1 and column_2 are numbers, the trigger above will make string versions of these numbers, concatenate them (with a hyphen between them), and put the results in the column VARCHAR2 column_3.
    So after this statement:

    INSERT INTO  table_x (column_1, column_2, column_3)
           VALUES          (1,     2,       '9-8');
    

    the new line will have column_3 = 1-2ยป (In this case, there is no point in explicitly implemented column_3, because the shutter always sets the value based entirely on colonne_1 and column_2.)

    If you need more information, post CREATE TABLE, INSERT and UPDATE statements and that you want the table to contain after each INSERT or UPDATE.

  • Can we use two columns AS a command

    Dear all,

    Please suggest

    I have two columns of different table and I want to make a general query selection of values in a table based on one exact string of others. Please find the following query:

    Select a.col1, b.col2
    FROM table1, table2 b
    where a.clo3 like b.col4;

    Now a.col3 values can be like "asbd %" or "qw %" or "% zx.
    where, as in b.col4 it will be asbd or qw or zx.

    Please suggest what I would do.

    Thanks in advance.
    Ankit Rana

    Hi, stone.

    Yes, you can use LIKE this way.

    Do not forget that AS is asymmetric:

    x LIKE y
    

    is usually not the same as

    y LIKE x
    

    because wildcard characters ('%' and '_') have a special meaning in the right operand, which is the expression that comes after LIKE.

    Anky rana says:
    Dear all,

    Please suggest

    I have two columns of different table and I want to make a general query selection of values in a table based on one exact string of others. Please find the following query:

    Select a.col1, b.col2
    FROM table1, table2 b
    where a.clo3 like b.col4;

    Now a.col3 values can be like "asbd %" or "qw %" or "% zx.
    where, as in b.col4 it will be asbd or qw or zx.

    So, it seems that you have to reverse the operands of TYPE:

    where   b.col4  like a.clo3;
    

    By the way, it's a matter of SQL, so a better forum for that would be the [SQL and PL/SQL forum | http://forums.oracle.com/forums/forum.jspa?forumID=75].

  • partition on two columns

    Hello
    I want to create partitions on two dates by the partition of the RANGE
    the dates are service_dt and process_dt these dates are different from the other
    When I try to use
    partition of range(service_dt,process_dt) gave me an error

    "ORA-14018: partition bound list contains too few elements.

    How can I make it clear that these two columns in create table statement
    so I have two separate partitions for each of them.

    any help is appreciated.
    Thanks in advance
    JP

    When you specify more than one column in the partitioning key, we hope that "n" dimensions of partitioning data, where n is the number of columns in the partitioning key. When the data are presented for the insertion, columns in the partition key are evaluated "from left to right" to determine the correct partition, the second partition key column) will be considered when the first column is not sufficient to determine the score.

    Also can you please put the entire table creation script.

  • Combine the two columns of text

    I have two columns of text (say that name is a column and the name is the other)

    I would like to combine the two columns for the text of these two columns are in a column. (First name and last name in the same column)

    Is this possible? If so is there a tutorial somewhere?

    Hi Danielle,

    The & (concatenation operator) is your friend.

    Formula in D2 (fill down)

    "B2 &" "& C2.

    & joins elements into a single string.

    "" inserts a space.

    Kind regards

    Ian.

  • Filter the rows in a table, based on criteria in two columns

    Is there a way easy to filter a 2d array, based on the values in two columns? For example in my attached VI the output array has the following format:

    10:57:07.776

    Quick response:

    Convert your table 2d in a cluster table where the order of pole defines how broken are managed (first fields are equa on both serach the second point in cluster)

    Run by a kind of 1 table and convert back to a 2d array.

    Faster approach:

    Group only fields serach and an index. Do the research and then use the index to reorganize the original array.

    Ben

  • SQL query * I want to insert a file column in the other table based on two columns

    I want to insert a column records to another table based on two columns

    the query below does not work

    insert into def_ver_lnki_p (job_name)

    Select def_job.job_name

    from def_job where def_job.job_id = def_ver_lnki_p.job_id and def_job.table_id = def_ver_lnki_p.table_id;

    Just to correct sql

    Update

    def_ver_lnki_p define job_name =)

    Select def_job.job_name

    of def_job

    where def_job.job_id = def_ver_lnki_p.job_id

    (and def_job.table_id = def_ver_lnki_p.table_id);

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

  • Starting from two data tables, how do you get the values in two columns using values in a column (values get col. If col. A is not null values and get the pass. B if col. A is null)?

    Two tables provided, how you retrieve the values in two columns using values in a column (the pass get values. If col. A is not null values and get the pass. B if col. A is null)?

    Guessing

    Select nvl (x.col_a, y.col_b) the_column

    from table_1 x,.

    table_2 y

    where x.pk = y.pk

    Concerning

    Etbin

  • To load excel spreadsheet oracle table by combining the values of the columns

    Hi all
    I need to load some data from excellent spreadsheet to a table, but on one condition.

    For example: If there are four columns in my excel sheet, the three combined columns must be loaded as a single column in my table and the last column in a separate column.

    for example: if my excel sheet has emp_no, emp_val, emp_id, emp_date lines and its values are 1,1,1,29 / 07 / 2011, then he must be loaded in my employee table of database like 111, 07-29-2011... What should I do? Please help me

    First, export your Excel spreadsheet to CSV. It is much simpler to work with text delimited by a binary property. Place the CSV file in a directory accessible to the database.

    Second, create an external table to select the data in the CSV file. Outdoor tables are very neat, once you get your head around them: basically we can execute SQL queries against the OS files. Declare the external table with four columns, i.e. its projection corresponds to the structure of your file. Learn more about the outdoor tables.

    (You will need create a DIRECTORY object to do this, pointing to the OS directory where you put the CSV file).

    Now its to a cinch to insert data into your target table:

    insert into target_table (col1, cols)
    select c1 || c2 || c3, c4
    from external_table
    /
    

    Cheers, APC

    Published by: APC Sep 14, 2011 14:49

    Published by: APC Sep 14, 2011 14:50

    Why is it so difficult to get things in shape? Grrr

Maybe you are looking for