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?

Tags: Database

Similar Questions

  • How to join two tables to retrieve the data from the columns in table two. Tables have primary and foreign key relationships

    Hello

    I want to join the two tables to retrieve the data from the columns of the two table passing parameters to the join query. Tables have primary and foreign key relationships

    Details of the table

    Alert-1 - AlertCode (FK), AlerID (PK)

    2 AlertCode-AlertDefinition-(PK)

    Help, please


    ----------

    Hi Vincent,.

    I think that you have not worked on adf 12.1.3.  In adf 12.1.3 you don't have to explicitly create the association. When you create the EO to your table, Association xxxxFkAssoc, will be created by ADF12.1.3 for you automatically. Please try this and do not answer anything... You can also follow the links below. I solved the problem by using the following link

    Oracle ADF Guide step by step - Oracle ADF tutorial: creating a relationship of the master / detail using Oracle ADF

    ---

  • How to join two tables of different schemas of Oracle by using a subquery

    I'm trying to join two different schemas of Oracle tables using a subquery. I can extract data from each of the tables without problem. However, when I combine select statements it by using a subquery I get Oracle error *'ORA-00936: lack of expression ' *. Given that each SELECT statement runs on its own without error I don't understand what's missing. I'm trying to get the result set is matching the LINE_ID of PDTABLE_12_1 in the schema with the table PDTABLE_201 MAT_DESCRIPTION DD_12809 in the RA_12809 schema.

    The query is as follows:

    SQL = "SELECT [DD_12809]. [PDTABLE_12_1]. LINE_ID OF [DD_12809]. [PDTABLE_12_1] JOIN "_".
    + "(SELECT [RA_12809]. [PDTABLE_201]. MAT_DESCRIPTION "_".
    "FROM [RA_12809]. [PDTABLE_201]) AS FAB "_".
    + 'ON [DD_12809]. [PDTABLE_12_1]. PIPING_MATER_CLASS = FAB. PIPING_MATER_CLASS ".

    The format of the request is copied from a manual of programming SQL.

    I also tried running the query uses a right JOIN on the two tables, but got the same results. Any ideas would be useful. Thank you!

    Published by: user11338343 on October 19, 2009 06:55

    The format for the join of two tables in Oracle feels like any other database:

    SELECT a.col1, a.col2, ..., b.col1, b.col2, ...
    FROM   schema1.table1 a,
           JOIN schema2.table2 b ON a.col = b.col and ...
    WHERE  a.other_col = 'FRED'
    AND    ....;
    

    Do not place bracketed identifiers in Oracle. The account that connects to the database must have select privileges on the two tables.

  • How to join two tables without constraints?

    I want to get back the tables to join without constraints!

    Table 1:

    get 100
    101 wet
    series 102

    and

    Table 2:

    10 xxx movies
    11 yyy
    12 zzz
    QUERY 1:

    SELECT * FROM TO LEAVE P, CUSTES C
    WHERE (P.ID, P.NAME, C.ID, C.NAME) IN (SELECT P1.ID, P1.NAME, C1.ID, C1.NAME
    OF P1, C1 CUSTES TO GO)

    I got the result like this,

    ID ID NAME
    101 wet 10 xxx
    zzz 101 wet 12
    YYY 101 wet 11
    Get 100 10 xxx
    102 the yyy 11 value
    series 102 10 xxx
    100 get 11 yyy
    100 get 12 zzz
    102 the value 12 zzz

    All ranks was sent three times! but I need to write once.

    QUERY 2:

    Select id as pid, name as the name of go
    Union
    Select id as pid, name as the name of custes;

    QUERY2 OUTPUT IS.

    NAME OF PID
    10 xxx movies
    11 yyy
    12 zzz
    get 100
    101 wet
    series 102

    In the 2nd query get the attached files of the two tables. But my need is two tables record to display like this

    ID NAME NAME_1 ID_1
    Get 10 xxx 100
    wet 11 101 yyy
    set of 12 zzz 102

    I'm looking for is, I want to join in parallel columns in my trips!

    Is there a source... ? or the same code is happy...!

    Something like that?

    WITH t1 AS (SELECT '100' id, 'get' name FROM DUAL
                UNION
                SELECT '101', 'wet' FROM DUAL
                UNION
                SELECT '102', 'set' FROM DUAL),
         t2 AS (SELECT '10' id, 'xxx' name FROM DUAL
                UNION
                SELECT '11', 'yyy' FROM DUAL
                UNION
                SELECT '12', 'zzz' FROM DUAL)
    SELECT id,
           name,
           (SELECT id
              FROM (SELECT ID, name, ROWNUM rw FROM t2) t_in
             WHERE t_in.rw = t_out.rw)
              id_1,
           (SELECT name
              FROM (SELECT ID, name, ROWNUM rw FROM t2) t_in
             WHERE t_in.rw = t_out.rw)
              name_1
      FROM (SELECT ID, name, ROWNUM rw FROM t1) t_out
    
    SQL> WITH t1 AS (SELECT '100' id, 'get' name FROM DUAL
      2              UNION
      3              SELECT '101', 'wet' FROM DUAL
      4              UNION
      5              SELECT '102', 'set' FROM DUAL),
      6       t2 AS (SELECT '10' id, 'xxx' name FROM DUAL
      7              UNION
      8              SELECT '11', 'yyy' FROM DUAL
      9              UNION
     10              SELECT '12', 'zzz' FROM DUAL)
     11  SELECT id,
     12         name,
     13         (SELECT id
     14            FROM (SELECT ID, name, ROWNUM rw FROM t2) t_in
     15           WHERE t_in.rw = t_out.rw)
     16            id_1,
     17         (SELECT name
     18            FROM (SELECT ID, name, ROWNUM rw FROM t2) t_in
     19           WHERE t_in.rw = t_out.rw)
     20            name_1
     21    FROM (SELECT ID, name, ROWNUM rw FROM t1) t_out;
    
    ID  NAME ID_1 NAME_1
    --- --- -- ---
    100 get 10 xxx
    101 wet 11 yyy
    102 set 12 zzz
    
    SQL>
    

    The number of rows in the tables are the same?

  • SQL: JOIN two table also corresponding column NULL how?

    Hello

    I'm trying to join two tables which works fine,
    But if there are NULL values, then, JOIN does not.
    I have two tables TEMP_DD AND TEMP_EE, in which two line
    is the column: allocation A_ID,.
    IE: 112 and NULL and I want both my sql output, but how?

    I tried under sql as it returns only a single line of 112 and does not return a null row which is a football game.


    SELECT * FROM TEMP_DD
    JOIN TEMP_EE
    ON (TEMP_DD.A_ID = TEMP_EE.A_ID);
    How to remedy this situation?

    create table TEMP_DD
    (
      A_ID VARCHAR2(3),
      B_ID VARCHAR2(4),
      C_ID VARCHAR2(10)
    );
    
    create table TEMP_EE
    (
      A_ID VARCHAR2(3),
      B_ID VARCHAR2(4),
      C_ID VARCHAR2(10)
    );
    
    insert into TEMP_DD (A_ID, B_ID, C_ID)
    values ('112', '1123', '12345678');
    insert into TEMP_DD (A_ID, B_ID, C_ID)
    values (NULL, '1123', '12345678');
    insert into TEMP_DD (A_ID, B_ID, C_ID)
    values ('212', '1123', '12345678');
    
    
    insert into TEMP_EE (A_ID, B_ID, C_ID)
    values ('112', '1123', '12345678');
    insert into TEMP_EE (A_ID, B_ID, C_ID)
    values (NULL, '1123', '12345678');
    insert into TEMP_EE (A_ID, B_ID, C_ID)
    values ('312', '1123', '12345678');
    OUTPUT
    ---------

    "112', ' 1123," "12345678".
    (NULL, ' 1123","12345678 ".

    Hello

    Wrap both sides in an NVL IE. NVL (col1, 'X'), WHERE = NVL(col2,'X').

    See you soon

    Ben

  • How to display two or more files on the screen at the same time in format "cascade" or "tile"?

    How to display two or more files on the screen at the same time in format "cascade" or "tile"?

    What types of files,

    He each file separately.

    Right-click your taskbar, and then click the option side by side...

    Breaking of Windows,

    http://Windows.Microsoft.com/en-us/Windows7/products/features/snap

    http://Windows.Microsoft.com/en-us/Windows7/arrange-Windows-side-by-side-on-the-desktop-using-snap

  • How can I join two tables that belong to two different databases?

    I can build a SQL query in SQL Server Management Studio, which performs a join of a table in a database with a table in another database.  I have a good 'read' name to username/password for the two databases.

    How to do the join in ColdFusion?  The tag < cfquery > requires a unique data source.  I could do like two queries and through comparing, or maybe even some use dbtype = query, but it would be horribly less effective than a direct join.

    I could place the SQL statement in a stored procedure, but that seems like overkill - all the necessary number of fields in the "WHERE" clause will change based on the logic of the ColdFusion program.

    Does anyone know of a way to do this with < cfquery >?

    How do you take in SQL Server Management Studio?  You must do something that I'm not aware, if what you're doing here does not work in a block.

    The way I did in the past is just to fully qualify the names of the tables.  Server.databaseOwner.database.table know if I remember correctly.

    This does not require that the database connected to the name of data source is configured to be allowed to connect to the database.

  • How to join two fields with slightly different data

    I have two columns, I need joined, both keep the columns of numeric data, but are of type varchar2 (6). The problem is that one of the columns keeps leading zeros to ensure that all 6 characters are used, but not the other. And columns preserve leading zeros may vary how many zeros are in the number-based computing.

    For example, the column with zeros can contain the number 4200, which would mean that he would remain with 2 zeros as 004200. Or it could contain 320, which means that he would remain with 3 zeros as 000320.

    The other column that does not have leading zeros not only keeps the number, so, in the example above, it would keep 4200 and 320 respectively.

    Can someone help on how to join these columns so that they match? I guess I have to delete the zeros in one or add zeros in the other? I tried to use the trunc with zeros on the ground, but it did not work...

    The following sql code:

    M06.mbr06_prv_id has no zeros, prv647.provider_id zeros. See bold below...

    SELECT
    M06.mbr06_prv_id,
    prv647.Site_ID
    Of
    Odw.mbr06_mbr_elig m06
    JOIN THE
    Odw.prv647_prov_exp prv647
    WE
    M06.mbr06_prv_id = prv647.provider_id
    WHERE
    M06.mbr06_subs_id = "999999999 '

    BTW, I have no control on how this data is represented in a table... !

    Hello

    user12296489 wrote:
    ... I guess I have to delete the zeros in one or add zeros in the other?

    Yes, this is how I see.
    LTRIM removes given characters from the beginning of a string. LPAD adds characters at the beginning of a string. I would use LTRIM in this case, because if you use LTRIM, you probably need to handle a single column. If you use LPAD, you have to play with the two columns, as one of them still has the extra 0, and it sometimes needs them.

    I tried to use the trunc with zeros on the ground, but it did not work...

    TRUNC is working on the kinds or DATEs; you have VARCHAR2s. You can convert them to numbers, but then you risk of errors to cause bad data (and it linked to the wrong data).
    >

    The following sql code:

    M06.mbr06_prv_id has no zeros, prv647.provider_id zeros. See bold below...

    SELECT
    M06.mbr06_prv_id,
    prv647.Site_ID
    Of
    Odw.mbr06_mbr_elig m06
    JOIN THE
    Odw.prv647_prov_exp prv647
    WE
    M06.mbr06_prv_id = prv647.provider_id
    WHERE
    M06.mbr06_subs_id = "999999999 '

    If you are certain that m06.mbr06_prv_id never has extra characters, whereas the join condition can be

    ON   m06.mbr06_prv_id   = LTRIM ( prv647.provider_id
                                      , '0'
                           )
    

    If this isn't the case, CUT then the two columns.

    BTW, I have no control on how this data is represented in a table... !

    Report a bad design is for people who don't have not this control. Numbers are the number of columns, not VARCHAR2. If the ID really needs to be strings, they should be validated and standardized once, when they are placed in the table, no more, and more, in all queries that use these columns.

    I hope that answers your question.
    If not, post a small example of data (CREATE TABLE and only relevant columns, INSERT statements) for all tables and also post the results desired from these data.
    Explain, using specific examples, how you get these results from these data.
    Always tell what version of Oracle you are using.

  • How interrogate in two tables

    Hi all
    How to query in two different tables? Use the following text

    SET_BLOCK_PROPERTY ('ins1', ONETIME_WHERE, ' series = "' |: OVERALL.) CODE | ''''); This works but for a single table if I want two tables and and display the information to the main form, for example... tables are referenced by a primary key constraint and foreign key.


    Sarah

    Published by: SarahSarahSarah on September 1, 2009 04:59

    Please try to create a relationship of block in your form.
    in the browser open the node of data blocks, then then INS1 node and click relationships.
    Click the green + * button on the left vertical toolbar.

    Block detail:
    PLATE type

    Deletions from Master:
    -In cascade (deletion details when the master is removed)

    Coordination:
    -Prevent the operation without a master

    Join:
    type (Word): REF
    do not select REF Object (this has nothing to do with your REF column!)

    Click OK and that's all.
    May you do not change or delete the new created triggers and program units to the
    you know what you're doing.

  • join two tables and results to display checkboxes checked... loop david powers please?

    Summary

    two tables:

    Table 1 categories

    Table 2A categories that someone has selected

    HTML form that updates the user's data:

    form should show all the options in the category dynamically in table 1

    and also to display the check box of the category as controlled dynamically if the person chose by table 2

    The nuts and bolts

    Attempt 1

    My sql:

    SELECT cat.id, cat.category, mcat.category as mcategory

    THE CAT of categories, members_categories mcat

    WHERE mcat.member_id = ' "." $_GET ['id']. »"

    ORDER BY category ASC

    (run on its own, all categories of table 1 are shown twice and the results of table 2 is a total cluster.)

    area of the form with checkboxes:

    <? PHP {? >}

    < input <? PHP if (!) ((strcmp($row_rsCategories['mcategory'],$row_rsCategories['id'])))) {echo ' checked =------'checked\' ' ;}?} > name = "category []" type = "checkbox" value = "<?" PHP echo $row_rsCategories ['id'];? ">" / > <? PHP echo $row_rsCategories ['category'];? > < br / >

    <? PHP} while ($row_rsCategories = mysql_fetch_assoc ($rsCategories));? >

    what I have here results:

    all categories displayed twice with selected categories of table 2 verified = by the results of sql when running alone

    Attempt 2

    My sql:

    SELECT cat.id, cat.category, mcat.category as mcategory

    CAT categories

    LEFT JOIN members_categories mcat WE mcat.category = cat.id

    WHERE mcat.member_id = ' "." $_GET ['id']. »"

    ORDER BY category ASC

    (run on its own, all categories of table 1 who have a match in the table 2 and none of the other in table 1 shows)

    area of the form with checkboxes:

    even the first attempt

    what I have here results:

    all categories selected in table 2 shows and checked, and no other choices of table 1 = by the results of sql when running alone

    Attempt 3

    My sql:

    SELECT cat.id, cat.category, mcat.category as mcategory

    THE CAT of categories, members_categories mcat

    WHERE mcat.member_id = ' "." $_GET ['id']. »"

    GROUP BY cat.id

    ORDER BY category ASC

    (running his own, all the choices in the category of table 1 are displayed, however, the mcategory column displays the lowest category numbered (same one) against all of these options rather then correspond to their.)

    area of the form with checkboxes:

    even the first attempt

    what I have here results:

    all choice of category in table 1 are displayed, however, only the first category in table 2 (which in this case is the lowest number) is marked as checked with the checkboxe, even if there is more then one category in table 2 = by the results of sql when running alone

    so, can anyone help?  I'm just banging my head against the wall here is something missing that should be obvious, because the sql is not giving me what I need to work with the form in a loop region.  Perhaps another approach should be taken and I have change the loop as well, but I think that this can be resolved with the sql.  Thanks in advance.

    Well, you can use two separate sql queries...

    one with the names of the categories

    and the second nested with the loop that references the id of category in table 1 to pair with table 2

  • How to link two tables with form

    Hello

    Here's what I want to do

    I have a table-> Student (rollno, name)

    I also have these two tables (rollno, marks) Math Physics (rollno, marks)

    now, I want to have a form in my page (in which I can navigate school records) and two tables in the adf (Math, physical). When selecting a certain record of the form, I want to see data associated with these two tables.

    I try to make the link display but works for me...

    Please help me on this.

    -Usman

    -Open the module of the application

    -Go to the model data tab

    -You will see all the your available on the left and your already added to the AM to the right

    -For the your who are 'master' for others your (in your case, student VO's master VO of Math and physics VO), you will see a (+) monkey behind it

    -Expand this node and you will see the math and physics your.

    -Math VO on the left and the VO student on the right then click on the button (>) to shuttle Math VO VO of the student child and give it a name

    -Repeat step for physics VO

    After completing the above steps and save, go back to your jsf (or jspx or...) and in the data tab control you will see this student VO is now two children, Math and physics. Use WHAT YOUR theses to create your tables for details.

    Kind regards.

  • JOIN the question... Join two tables without omitting lines

    I came across a problem that should be an easy fix (I hope), but I'm having a hard time to come up with a solution.

    Basically I have two tables, one with the actual amounts with the budget. I have to write a sql statement select that joins these tables together and includes all of their lines. I was able to join the tables by using JOIN, LEFT JOIN and RIGHT JOIN, but it always fails the lines I need.

    Below, I have examples of my tables (AMOUNT_TABLE and BUDGET_TABLE). For simplicity, I built the examples to show the same values in the first four columns, with the 5th and 6th columns (SUB_ACCOUNT, AMOUNT, BUDGET) as the only values that are different. My actual tables are not quite that simple, but I don't think it was relavent to this issue.

    AMOUNT_TABLE

    FISCAL_YEAR PERIOD ACCT_UNIT ACCOUNT SUB_ACCOUNT AMOUNT

    2013

    111111555555000010020131111115555551000100201311111155555520001002013111111555555300010020131111115555554000100

    BUDGET_TABLE

    FISCAL_YEAR PERIOD ACCT_UNIT ACCOUNT SUB_ACCOUNT BUDGET

    2013

    1111115555553000200201311111155555540002002013111111555555500020020131111115555556000200

    Here's what I hope. Note that SUB_ACCOUNTs 0000, 1000, and 2000 show without budget amounts since there is not a corresponding line in the BUDGET_TABLE. And same for SUB_ACCOUNTs 5000 and 6000, they show budgets with no amount because there is not a corresponding line in the AMOUNT_TABLE.

    (exit)

    FISCAL_YEAR PERIOD ACCT_UNIT ACCOUNT SUB_ACCOUNT AMOUNT BUDGET
    201311111155555500001000
    201311111155555510001000
    201311111155555520001000
    20131111115555553000100200
    20131111115555554000100200
    201311111155555550000200
    201311111155555560000200

    If all goes well, my question is clear. Any help on this would be greatly appreciated. Thanks in advance.

    Use the join ANSI - FULL OUTER JOIN syntax:

    with amount_table like)

    Select fiscal_year 2013, 1 period, 11111 acct_unit, 555555, 0000 sub_account, amount 100 of all the double union

    Select 2013,1,11111,555555,1000,100 from all the double union

    Select 2013,1,11111,555555,2000,100 from all the double union

    Select 2013,1,11111,555555,3000,100 from all the double union

    Select double 2013,1,11111,555555,4000,100

    ),

    budget_table like)

    Select 1 time, 11111 acct_unit, account 555555, sub_account 3000, 2013 fiscal_year, budget of 200 Union double all the

    Select 2013,1,11111,555555,4000,200 from all the double union

    Select 2013,1,11111,555555,5000,200 from all the double union

    Select double 2013,1,11111,555555,6000,200

    )

    Select nvl (a.fiscal_year, b.fiscal_year) fiscal_year,

    period of NVL (a.period, b.period),

    NVL (a.acct_unit, b.acct_unit) acct_unit.

    account of NVL (a.Account, b.Account),

    NVL (a.sub_account, b.sub_account) sub_account.

    Amount NVL(a.amount,0),

    NVL(b.budget,0) budget

    of amount_table one

    full join

    budget_table b

    on)

    a.Fiscal_Year = b.fiscal_year

    and

    a.period = b.period

    and

    a.acct_unit = b.acct_unit

    and

    a.Account = b.account

    and

    a.sub_account = b.sub_account

    )

    /

    FISCAL_YEAR PERIOD ACCT_UNIT ACCOUNT SUB_ACCOUNT AMOUNT BUDGET
    ----------- ---------- ---------- ---------- ----------- ---------- ----------
    2013 1 11111 555555 0 100 0
    2013 1 11111 555555 1000 100 0
    2013 1 11111 555555 2000 100 0
    2013 1 11111 555555 3000 100 200
    2013 1 11111 555555 4000 100 200
    2013 1 11111 555555 6000 0 200
    2013 1 11111 555555 5000 0 200

    7 selected lines.

    SQL >

    SY.

  • Outside to join two tables

    I had two Tables.APPROVAL_ROUTING_TAB and doc_issue_tab, where APPROVAL_ROUTING_TAB has more lines. I need to make a join of two tables such as all APPROVAL_ROUTING_TAB lines should be displayed (multiple lines) but always connect with the doc_issue_tab. I did an outer join syntax failed.
    What is the correct syntax for this.
    Key_ref takes the outline "DOC_CLASS = PR_CLASS_1 ^ DOC_NO = 1000007 ^ DOC_REV = A3 ^ DOC_SHEET = 1 ^ '.

    SELECT
    AR.line_no LINE_NO,
    AR.step_no STEP_NO,
    AR.lu_name LU_NAME,
    AR.key_ref KEY_REF,
    AR. Description DESCRIPTION,
    di. Status STATUS
    From ar APPROVAL_ROUTING_TAB, doc_issue_tab di
    WHERE
    AR.key_ref = 'DOC_CLASS =' | di. DOC_CLASS |' ^ DOC_NO =' | di.doc_no: ' ^ DOC_REV =' | di.doc_rev: ' ^ DOC_SHEET =' | di.doc_sheet: ' ^') (+)

    Thanks in advance
    Prash

    Here is an example:

    with t1 as (select 1 id, 'd1=fred^d2=john^d3=bob^' col2 from dual union all
                select 1 id, 'd1=fred^d2=john^d3=george' col2 from dual),
         t2 as (select 'fred' d1, 'john' d2, 'bob' d3 from dual union all
                select 'jim' d1, 'john' d2, 'bob' d3 from dual)
    select *
    from   t1, t2
    where  t1.col2 = 'd1='||d1(+)||'^d2='||d2(+)||'^d3='||d3(+)||'^';
    
            ID COL2                      D1   D2   D3
    ---------- ------------------------- ---- ---- ---
             1 d1=fred^d2=john^d3=bob^   fred john bob
             1 d1=fred^d2=john^d3=george              
    
  • 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: -.

  • How to make two spider Bridge version in the collection of Windows Solitaire?

    Original title: solitaire suited spider 2

    I downloaded collection windows solitaire and got a suit spider solitaire.  How two spider Bridge version?

    Hi Jeanne,

     

     

    Thanks for posting your question in the Microsoft Community.

    I imagine the inconvenience that you are experiencing. I will certainly help the question of fixing.

    To help you suggest several steps to solve the problem, I would appreciate if you could answer the following questions:

     

    . Where did you downloaded Windows solitaire collection?

    I suggest you to check the Web site where you downloaded the game or your favorite search engine about the research question.

    The default games in Windows Vista in mentioned in the link below:

    Discover games in Windows Vista:

    http://Windows.Microsoft.com/en-us/Windows-Vista/learn-about-Windows-games

     

     

    Your response is very important for us to ensure a proper resolution. Please get back to us to help you accordingly.

     

Maybe you are looking for