Help required in sql join

Hello friends,

.

I am trying to query a record of two Emp and Dept tables, I would like to know where employee works (location is stored in)
the Dept table) and would like to employee knowledge belongs to what manager Id stored in the Emp table.

The query below don't give me the desired output. Please suggest me something.

SELECT
E1. EMPNO,
E1. ENAME,
E1. EMPLOYMENT,
E1. SAL,
E1. DEPTNO,
TO_CHAR (E1. HIREDATE, 'DD-MM-YYYY') HIRE_DATE,.
D.LOC,
E1. ENAME Manager
EMP E1, E2 EMP, DEPT. D
WHERE E1. DEPTNO = D.DEPTNO
AND E2. MGR = E1. EMPNO;

Had

Next time ask similar questions in the sql forum
SQL and PL/SQL

Answer to your question is
(based on the assumption MGR_NO column exists and is Manager empno)
SELECT E1. EMPNO,
E1. ENAME,
E1. EMPLOYMENT,
E1. SAL,
E1. DEPTNO,
TO_CHAR (E1. HIREDATE, 'DD-MM-YYYY') HIRE_DATE,.
D.LOC,
E2. ENAME Manager
EMP E1, E2 EMP, DEPT. D
WHERE E1. DEPTNO = D.DEPTNO AND E2. EMPNO = E1. MGR_NO;

Tags: Oracle Applications

Similar Questions

  • Help required in SQL query

    I have a table and passes as below:

    START DATE TOTAL NUMBER OF DAYS
    11/10/2011 15:00 1
    15/10/2011-05:00 1
    2011-12-22 10:00 1
    22/12/2011 11:00 2
    30/12/2011-10:00 1
    01/01/2012 01:00 1
    01/01/2012 10:00 1
    01/01/2012 16:00 2
    02/01/2012 14:00 1
    03/01/2012-15:00 1
    04/01/2012-15:00 2
    04/01/2012 18:00 1



    I need to ask where the values in the table above
    must return values as below:

    I tried many ways, but not able to find the solution.

    Kindly help me in this regard.


    START DATE TOTAL NUMBER OF DAYS
    11/10/2011 15:00 1
    15/10/2011-05:00 1
    22/12/2011 11:00 2
    30/12/2011-10:00 1
    01/01/2012 16:00 2
    02/01/2012 14:00 1
    03/01/2012-15:00 1
    04/01/2012-15:00 2


    the ultimate goal is to summarize the TOTAL number of DAYS column all the numbers in the second table... All jobs must be treated in the same query. I can't use the coding of java to process what my requirement should be included in the query that already exists.

    Published by: 915175 on February 16, 2012 23:02
    select trunc(start_date), max(start_date), max(total_days) from tablename
    group by trunc(start_date);
    

    Please check below is on my local site with you Test data:

    SQL>
    SQL> with tablename as
      2  (
      3  select to_date('10/11/2011 15:00' , 'mm/dd/yyyy hh24:mi') start_date,  1 total_days from dual union all
      4  select to_date('10/15/2011 5:00' , 'mm/dd/yyyy hh24:mi') start_date,  1 total_days from dual union all
      5  select to_date('12/22/2011 10:00' , 'mm/dd/yyyy hh24:mi') start_date,  1 total_days from dual union all
      6  select to_date('12/22/2011 11:00' , 'mm/dd/yyyy hh24:mi') start_date,  2 total_days from dual union all
      7  select to_date('12/30/2011 10:00' , 'mm/dd/yyyy hh24:mi') start_date,  1 total_days from dual union all
      8  select to_date('1/1/2012 1:00' , 'mm/dd/yyyy hh24:mi') start_date,  1 total_days from dual union all
      9  select to_date('1/1/2012 10:00' , 'mm/dd/yyyy hh24:mi') start_date,  1 total_days from dual union all
     10  select to_date('1/1/2012 16:00' , 'mm/dd/yyyy hh24:mi') start_date,  2 total_days from dual union all
     11  select to_date('1/2/2012 14:00' , 'mm/dd/yyyy hh24:mi') start_date,  1 total_days from dual union all
     12  select to_date('1/3/2012 15:00' , 'mm/dd/yyyy hh24:mi') start_date,  1 total_days from dual union all
     13  select to_date('1/4/2012 15:00' , 'mm/dd/yyyy hh24:mi') start_date,  2 total_days from dual union all
     14  select to_date('1/4/2012 18:00' , 'mm/dd/yyyy hh24:mi') start_date,  1 total_days from dual
     15  )
     16  select  TO_CHAR(max(start_date),'MM/DD/YYYY HH24:MI') start_date , max(total_days) total_days from tablename
     17  group by trunc(start_date);
    
    START_DATE       TOTAL_DAYS
    ---------------- ----------
    10/15/2011 05:00          1
    01/03/2012 15:00          1
    12/30/2011 10:00          1
    01/01/2012 16:00          2
    10/11/2011 15:00          1
    12/22/2011 11:00          2
    01/04/2012 18:00          2
    01/02/2012 14:00          1
    
    8 rows selected.
    
    SQL>
    

    Kind regards
    Lifexisxnotxsoxbeautiful...

    Update: added test done to my database...

    Edited by: lifexisxnotxsoxbeautiful Vithalani, on February 16, 2012 23:18

  • Help required with SQL query

    I have three tables listed below

    FORMAT - Columns are format_id, format_desc
    VIDEO_FORMAT - areVIDEO_FORMAT_ID of columns, COST VIDEO_ID, FORMAT_ID,
    RENTAL - Coulmns are RENTAL_ID, DATE_OUT, DATE_DUE, DATE_IN, DELIVERY_STATUS, LATE_FEE, CUSTOMER_ID, VIDEO_FORMAT_ID

    I need to find the customer list id, format description and cost of the video format for customers who have rented a video.

    I wrote the request

    Select rental r format f, video_format, r.customer_id, f.format_desc, vf.cost vf where f.format_id in (select video_format format_id) and r.video_format_id = vf.video_format_id

    This isn't to get accurate results. Help, please.

    Would know what kind of results you get, but I think that I can see.

    Try:
    Select r.customer_id, f.format_desc, vf.cost
    rental r, f format, video_format vf
    where vf.format_id = f.format_id
    and r.video_format_id = vf.video_format_id

    Can't be sure without a little more information so that will set you. But I do not know why you went with trying to get a relationship using an IN with a subquery. It will be useful.

  • Help required in SQL

    Hi all

    I used the SUM on the Partition by for a select query. But, I need to restrict this SUM for a reception.

    I have 10 recipes, then this function should calculate only for reception only. But in my case it's in summary for all receipts.

    can anyone suggest me how to use function for this group?

    Kind regards
    Suresh Reddy

    Suresh Reddy wrote:

    But, if I need to re group the TAX lines then what we should do?

    You must explain in more detail. You can use separate columns or partition in reception, tax:

    SQL> select  deptno,
      2          job,
      3          ename,
      4          sal,
      5          sum(sal) over(partition by deptno) total_dept_sal,
      6          sum(sal) over(partition by job) total_job_sal,
      7          sum(sal) over(partition by deptno,job) total_dept_job_sal
      8    from  emp
      9    order by deptno,
     10             job
     11  /
    
        DEPTNO JOB       ENAME             SAL TOTAL_DEPT_SAL TOTAL_JOB_SAL TOTAL_DEPT_JOB_SAL
    ---------- --------- ---------- ---------- -------------- ------------- ------------------
            10 CLERK     MILLER           1300           8750          4150               1300
            10 MANAGER   CLARK            2450           8750          8275               2450
            10 PRESIDENT KING             5000           8750          5000               5000
            20 ANALYST   SCOTT            3000          10875          6000               6000
            20 ANALYST   FORD             3000          10875          6000               6000
            20 CLERK     ADAMS            1100          10875          4150               1900
            20 CLERK     SMITH             800          10875          4150               1900
            20 MANAGER   JONES            2975          10875          8275               2975
            30 CLERK     JAMES             950           9400          4150                950
            30 MANAGER   BLAKE            2850           9400          8275               2850
            30 SALESMAN  TURNER           1500           9400          5600               5600
    
        DEPTNO JOB       ENAME             SAL TOTAL_DEPT_SAL TOTAL_JOB_SAL TOTAL_DEPT_JOB_SAL
    ---------- --------- ---------- ---------- -------------- ------------- ------------------
            30 SALESMAN  MARTIN           1250           9400          5600               5600
            30 SALESMAN  WARD             1250           9400          5600               5600
            30 SALESMAN  ALLEN            1600           9400          5600               5600
    
    14 rows selected.
    
    SQL> 
    

    SY.

  • help on SQL JOIN Conversion of ANSI STANDARD

    SELECT Q.FLDQUESTION, Q.FLDCMNTPRMT, Q.FLDISHEAD, Q.FLDCODE, M.FLDDATA, A.FLDYESNO, C.FLDDATA
    OF CANQSTN Q,.
    LOGCAANS, A.
    CANQSTN_MEMO M.
    C LOGCAANS_MEMO
    WHERE A.FLDCASE =? AND
    Q.FLDCODE = A.FLDQUESTION AND
    Q.FLDPOSSCACT * = M.FLDREC_NUM (+) AND
    A.FLDCOMMENT * = C.FLDREC_NUM (+)
    ORDER BY A.FLDSEQUENCE

    This request must be converted to ANSI Standard SQL JOIN.

    SELECT Q.FLDQUESTION, Q.FLDCMNTPRMT, Q.FLDISHEAD, Q.FLDCODE, M.FLDDATA, A.FLDYESNO, C.FLDDATA
    OF (inner CANQSTN Q join A LOGCAANS on Q.FLDCODE = A.FLDQUESTION)
    LEFT OUTER JOIN CANQSTN_MEMO M ON Q.FLDPOSSCACT = M.FLDREC_NUM
    Here, I stuck with join remaining 2 tables A.FLDCOMMENT * = C.FLDREC_NUM (+)
    could you any body please help me on this query.

    JOURNAL OF LOGCAANS, CANQSTN TABLES REFERENCES.

    Hello, here is the equivalent ANSI JOIN:

    SELECT Q.FLDQUESTION, Q.FLDCMNTPRMT, Q.FLDISHEAD, Q.FLDCODE,
         M.FLDDATA, A.FLDYESNO, C.FLDDATA
      FROM CANQSTN Q
      JOIN LOGCAANS ON (Q.FLDCODE = A.FLDQUESTION)
      LEFT JOIN CANQSTN_MEMO M ON (Q.FLDPOSSCACT = M.FLDREC_NUM)
      LEFT JOIN LOGCAANS_MEMO C ON (A.FLDCOMMENT = C.FLDREC_NUM)
     WHERE A.FLDCASE = ?
     ORDER BY A.FLDSEQUENCE;
    
  • Need help with a SQL query

    Hello

    I have a data in table (raj_table) with columns (char11) raj_id, raj_number (varchar2 (15)), raj_format (NUMBER), Primary_ID (identity with the values of the primary key column)

    Primary_ID raj_id Raj_number Raj_format

    1                            raj                 rajvend                      1

    2                            raj                 rajvend                      1

    3                            raj                 rajvendor1                 2

    4                            raj                 rajvendor1                 2

    5                            raj                 rajvendor1                 2

    6                            raj                 rajvendor2                 3

    I used under SQL to get query output as below, but has not achieved the required result:

    Select client_id vendor_number, vendor_format, primary_id, row_number() on sl_no (client_id partition, primary_id, vendor_format order of client_id primary_id, vendor_format, vendor_number, vendor_number)

    from raj_table by sl_no asc

    SL_NO raj_id raj_number raj_format primary_id

    1                   1                   raj              rajvendor                 1

    1                   2                  raj              rajvendor                 1

    2                   3                   raj              rajvendor1                2

    2                   4                   raj              rajvendor1                2

    2                   5                  raj               rajvendor1                2

    3                   6                    raj              rajvendor2                3

    I need help with a SQL query to get the result as above without using the group by clause. I want to bring together the combination of separate line of the three columns (raj_id, raj_number, raj_format) and add a unique serial number for each online game (SL_NO column below). So, above there are 3 unique set of (raj_id, raj_number, raj_format) I can get in a group by clause, but I can not add prmiary_id, SL_NO values if I group by clause. I used the analytical functions like row_number() but no luck. Need solution for this.

    with t as)

    Select 'raj' raj_id, 'rajvend' raj_number, 1 raj_format, 1 primary_id Union double all the

    Select option 2, 'raj', 'rajvend', 1 double Union all

    Select 3, 'raj', 'rajvendor1', 2 double Union all

    Select 4, 'raj', 'rajvendor1', 2 double Union all

    Select 5, 'raj', 'rajvendor1', 2 double Union all

    Select 6, 'raj', 'rajvendor2', 3 double

    )

    Select dense_rank() over (order of raj_id, raj_number, raj_format) sl_no,

    t.*

    t

    order by primary_id

    /

    PRIMARY_ID RAJ RAJ_NUMBER RAJ_FORMAT SL_NO
    ---------- ---------- --- ---------- ----------
    1 1 raj rajvend 1
    1 2 raj rajvend 1
    2 3 raj rajvendor1 2
    2 4 raj rajvendor1 2
    2 5 raj rajvendor1 2
    3 6 raj rajvendor2 3

    6 selected lines.

    SQL >

    SY.

  • help required on table transpose

    DATA IN THE TABLE:

    ST IC OC         

    I have 18 2

    20 4 K

    10 1 L

    where ST, IC and OC are names of columns and I want data from the table format below. Please help,

    I K L         

    IC 18 20 10

    OC       2    4      1

    Hello

    Visit these pages to learn how to rotate the data:

    http://forums.Oracle.com/forums/thread.jspa?MessageID=4347279�

    http://forums.Oracle.com/forums/thread.jspa?MessageID=3662005

    If you don't know not set an upper limit for the number of columns in the result, swing requires dynamic SQL and I recommend you rather use String aggregation , where the output is a column of the great string, format to watch as separate columns.

    If you get stuck, post your best attempt, as well as some examples of data (CREATE TABLE and only relevant columns, INSERT statements) and the desired results from these data.

    Always say what version of Oracle you are using (for example, 11.2.0.2.0).

    See the forum FAQ https://forums.oracle.com/message/9362002#9362002

  • Please help build a sql query

    Hello

    Please help build a sql query


    My Table Test2015 has given below

    Header_id Line_id Ordered_item       

    723887290 199925 MAIN1

    199925 723887291 MAIN2

    199926 723887292 SH-POS-NO-BR POS-INS

    199926 723887293 MAIN2

    199927 723887294 IC-ENV-NON-BR-ENV-PXY

    199927 723887295 MAIN1

    199927 723887297 MAIN2

    199927 723887298 PRCSS SH-FAIRY-ELEC DISTR.

    199927 723887299 SH-FAIRY-SUM PRO-DE-CONS-HOUSE

    I am trying to query my Test2015 table to obtain the records with ordered_item containing 'MAIN1' and 'MAIN2' only. I tried to write a query as below

    SELECT * FROM test2015 WHERE ORDERED_ITEM in ('MAIN1', 'MAIN2');

    But it gives me all the data with the MAIN2 records found but MAIN1 is absent, I want to retrieve only records to both 'MAIN1' and 'MAIN2' present for Header_id.

    While the result below shows me header_id - 199926 and 199929 that he should assume back. I want to fetch documents only with 'MAIN1' and 'MAIN2' both present.

    Header_id Line_id Ordered_item            

    723887290 199925 MAIN1

    199925 723887291 MAIN2

    199926 723887293 MAIN2

    199927 723887295 MAIN1

    199927 723887297 MAIN2

    199929 723887299 MAIN1

    Please suggest.

    Thank you and best regards,

    Prasad.

    Hello

    Try like this...

    SELECT * FROM test2015 WHERE ORDERED_ITEM in ('MAIN1") and in header_id (select test2015 WHERE ORDERED_ITEM in ('MAIN2') header_id)

  • What is the new method of SQL joins

    Dear all,

    What is the new method of SQL joins

    1

    SELECT <fields>
      FROM TableA a INNER JOIN TableB b ON a.key = b.key
    

    2

    SELECT <fields>
      FROM TableA a, TableB b
     WHERE a.key = b.key
    

    Above the two queries work very well in PL/SQL, but request that no 1 does not work in Oracle Forms 10 g

    Kind regards

    Zafar Iqbal

    Hello

    Zafar Iqbal wrote:

    Dear all,

    What is the new method of SQL joins

    1

    1. SELECT
    2. TableA, TableB INNER JOIN a and b WE a.key, b.key =

    2

    1. SELECT
    2. FROM TableA, TableB b
    3. WHERE a.key, b.key =

    Above the two queries work very well in PL/SQL, but request that no 1 does not work in Oracle Forms 10 g

    Kind regards

    Zafar Iqbal

    What, exactly, is your question?

    Literally ask you which of these 2 methods is new?  As mentioned above, none is really new.  Both participated in Oracle at least 13 years.

    Query 1, above, ANSI join syntax uses, which is more recent.   As mentioned above, Oracle has started to support that the syntax in version 9.1 (2001) previous versions only supported syntax used in query 2.

    Did you mean to ask something else?  Maybe "How can I use a query as a query 1 forms?" or "are there other places where a method works, but the other is not?

  • Help me with SQL Query to retrieve data from a view

    Hello Guru,

    I need help in my sql query.
    I use SQL TeraData.
    I want an Oracle result in the following form-

    Open tickets
    Open months failure / Repair Service s/o improvement request Total general
    2009-01-2 4 4 5 15
    2009-02 1 0 2 3 6
    2009-03 4 1 2 2 9
    Grand Total 7 5 8 10 30


    I wrote the query as where - TIME_PERIOD, RQST_TYPE_DM and DEMAND_SUMMARY_FCT are the points of view and I extract the data from the views only.

    Select NVL (CA. TIME_PERIOD. PERIOD_CD, 'Total') THAT year.
    COUNT (CASE WHEN CA. RQST_TYPE_DM. RQSTTYP_DESC Like '% of Break' THEN 1 END) as BreakFix
    COUNT (CASE WHEN CA. RQST_TYPE_DM. RQSTTYP_DESC as 'N/a', 1 END) by n/a
    COUNT (CASE WHEN CA. RQST_TYPE_DM. RQSTTYP_DESC as 'Improvement' THEN 1 END) accessories
    COUNT (CASE WHEN CA. RQST_TYPE_DM. RQSTTYP_DESC Like '% Service' THEN 1 END) as ServiceRequests
    COUNT (CA. RQST_TYPE_DM. RQSTTYP_DESC) AS grand_total
    FROM CA. TIME_PERIOD, CA. RQST_TYPE_DM, CA. DEMAND_SUMMARY_FCT
    WHERE (CA. DEMAND_SUMMARY_FCT. RQSTTYP_ID = CA. RQST_TYPE_DM. RQSTTYP_ID)
    AND (CASE
    WHEN CA. DEMAND_SUMMARY_FCT. MONTH_ID = CA. TIME_PERIOD. PERIOD_ID, 1
    WHEN {fn concat ({fn concat (SUBSTR (CA. TIME_PERIOD. {(PERIOD_CD, 3, 4),'-')}, SUBSTR (CA. TIME_PERIOD. PERIOD_CD, 7, 2))} BETWEEN ' 2009-01' AND ' 2009-03' THEN 1
    WHEN CA. DEMAND_SUMMARY_FCT. RQSTTYP_ID = '1' then 1
    END) = 1
    GROUP BY ROLLUP (CA. TIME_PERIOD. PERIOD_CD)

    After executing the query, I get the following error:
    3076: syntax Error: Data Type 'Time' does not match a defined Type name.
    :( Kindly help me with this and let me know where I'm wrong... Please.

    Messages indicates something wrong with your data... It would seem that the data does not match your format mask.

    Thus, the data or the format mask.

  • Help required to query the fields of the shuttle to Table?

    Hi Experts,

    My needs:

    1. According to the Ship Date query field, the item number should display in the console on the left.
    2. Select some amendments point shuttle from left to right shuttle and press the button.
    3. the article selected our and these details must display in the table.

    Design:

    1 created as query field (entry of Message text) shipping Date.
    2 Shuttle, Shuttle flight beginning and footer (second query button).
    3. the table that contains the article, Description, quantity, and manufacturing details no.

    Question:

    I created a shuttle, the creeping shuttle and the flight of footer, here I mentioned the VO attribute and discovers for the first query that takes place in shipping date and displays the item No.

    By default (without question) the extension numbers is the display in the shuttle leading.

    How to use the fields in the query of the shuttle. Its not that allows you to query the selected fields.

    Help required:

    I need to ship date, then the element of the request should appear in the console of leak, then I need to move some element not in the shuttle leading and click on the second button of the query.

    All required according to the shipping date and the amendments point values (Selected in the shuttle leading) must display in the table.

    Thank you
    Corinne Bertrand

    Pass this date and form a condition, and re-run the LEADVO

    Anne Marie

  • Help: APEX - PL/SQL function

    Hello
    I need help with a SQL statement.
    I have the text following table 'TABF ':
    ID Number,
    B_Number varchar2(10),
    G_Type varchar2(10),
    Site varchar2(50),
    Event varchar2(50),
    Date varchar(10),
    Dataset varchar2(50),
    Mode varchar2(50),
    Topic varchar2(10),
    Parameter varchar2(10),
    Value varchar2(10)
    The table is filled with records that, like this:
    B Number | G-Type |Site       |Event  |Date     | Dataset   | Mode    | Topic    | Parameter | Value 
    800257   |   4.2  |  USA      | Test  |18.08.08 | Pre       |MBA      | Field    | F_C       | 73,9015  
    800257   |   4.2  |  USA      | Test  |03.04.96 | BL        |MBA      | Field    | F_C       | 73,6951  
    800257   |   4.2  |  USA      | Test  |03.04.96 | BL        |MBA      | Field    | F_C       | 73,71  
    800257   |   4.2  |  USA      | Test  |18.08.08 | Post      |MBA      | Field    | F_C       | 73,7526  
    800257   |   4.2  |  USA      | Test  |18.08.08 | Pre       |MBA      | Field    | F_C       | 4,5170  
    800257   |   4.2  |  USA      | Test  |03.04.96 | BL        |MBA      | Field    | F_H       | 24,6074  
    800257   |   4.2  |  England  | Test  |03.04.96 | BL        |MBA      | Field    | F_H       | 24,62  
    800257   |   4.2  |  England  | Test  |18.08.08 | Post      |MBA      | Field    | F_H       | 24,4717  
    Now I am looking for an instruction SELECT or better a function that returns a select under the following condition:
    If B_Number and event and Date Dataset are equal, then add 3 additional columns (Topic2, Paramter2, value2) for the first entry equivalent.
    Then the line can be remove / ignored. If there will be another record where B_Number, events, Date correspond to a line above then Topic3, Paramter3 and 3 value add as a new column in the first record, where the conditions is equal to.
    And so on...

    The result should look like this for the example above:
    B Number | G-Type |  Site     |Event  |Date     | Dataset   | Mode    | Topic    |Parameter   | Value    | Topic2   |  Parameter2  | Value2
    800257   |    4.2 |  USA      | Test  |18.08.08 | Pre       | MBA     | Field    | F_C        | 73,9015  | -        | -            | -
    800257   |    4.2 |  USA      | Test  |03.04.96 | BL        | MBA     | Field    | F_C        | 73,6951  | Field    | F_H          | 24,6074 
    800257   |    4.2 |  USA      | Test  |03.04.96 | BL        | MBA     | Field    | F_C        | 73,71    | Field    | F_H          | 24,62  
    800257   |    4.2 |  USA      | Test  |18.08.08 | Post      | MBA     | Field    | F_C        | 73,7526  | -        | -            | -
    800257   |    4.2 |  USA      | Test  |18.08.08 | Pre       | MBA     | Field    | F_C        | 4,5170   | -        | -            | -
    800257   |    4.2 |  England  | Test  |18.08.08 | Post      | MBA     | Field    | F_H        | 24,4717  | -        | -            | -
    Hope you understand my problem and some1 can help me.
    Thank you
    Concerning
    Chris

    Published by: user11369135 on 09.07.2009 00:50

    user11369135 wrote:
    First of all thank you for your suggestions and for the quick response to my problem.

    I used the code of Alex Nuijten,
    his works very well... Thanks for that.

    You are welcome.. http://forums.Oracle.com/forums/Ann.jspa?annID=719

    If a line has empty "slots", those are met with a mix of topics, the parameters and values until the entire column of the select statement is full.

    What you mean? Can you show an example of "that's how it is now and is what they want.

    I tried to change the "in order to", but this isn't the solution.

    This is part of the analytical function, learn how they work.

  • Help with making SQL query references to column aliases in the Case statement

    I need help with a sql query that I'm trying. I can go about it the wrong way, but I would be grateful if I could get any suggestions on possible solutions. This is my query:


    SELECT DISTINCT spriden_pidm, spriden_id id, spriden_last_name | ',' | spriden_first_name name,

    CASE
    WHEN rcresar_comm_code_01 IN ('268 ', '269', ' 270') THEN rcresar_comm_code_01
    WHEN rcresar_comm_code_02 IN ('268 ', '269', ' 270') THEN rcresar_comm_code_02
    WHEN rcresar_comm_code_03 IN ('268 ', '269', ' 270') THEN rcresar_comm_code_03
    WHEN rcresar_comm_code_04 IN ('268 ', '269', ' 270') THEN rcresar_comm_code_04
    WHEN rcresar_comm_code_05 IN ('268 ', '269', ' 270') THEN rcresar_comm_code_05
    WHEN rcresar_comm_code_06 IN ('268 ', '269', ' 270') THEN rcresar_comm_code_06
    WHEN rcresar_comm_code_07 IN ('268 ', '269', ' 270') THEN rcresar_comm_code_07
    WHEN rcresar_comm_code_08 IN ('268 ', '269', ' 270') THEN rcresar_comm_code_08
    WHEN rcresar_comm_code_09 IN ('268 ', '269', ' 270') THEN rcresar_comm_code_09
    WHEN rcresar_comm_code_10 IN ('268 ', '269', ' 270') THEN rcresar_comm_code_10
    END acg_elig_comm_code

    CASE
    WHEN acg_elig_comm_code = ' 268' THEN 'rigorous HS course. "
    WHEN acg_elig_comm_code = '269' THEN ' 2 or several AP or IB"
    WHEN acg_elig_comm_code = '270' THEN 'NOC as possible ".
    END comm_code_description

    OF spriden, rcresar, rcrapp1

    WHERE (rcresar_comm_code_01 IN ('268 ', '269', ' 270')

    OR rcresar_comm_code_02 ('268 ', '269', ' 270')

    OR rcresar_comm_code_03 ('268 ', '269', ' 270')

    OR rcresar_comm_code_04 ('268 ', '269', ' 270')

    OR rcresar_comm_code_05 ('268 ', '269', ' 270')

    OR rcresar_comm_code_06 ('268 ', '269', ' 270')

    OR rcresar_comm_code_07 ('268 ', '269', ' 270')

    OR rcresar_comm_code_08 ('268 ', '269', ' 270')

    OR rcresar_comm_code_09 ('268 ', '269', ' 270')

    OR rcresar_comm_code_10 ('268 ', '269', ' 270'))


    Rcresar_aidy_code = & aidy_code

    AND rcrapp1_aidy_code = rcresar_aidy_code

    AND rcrapp1_curr_rec_ind = 'Y '.

    AND rcrapp1_seq_no = rcresar_seq_no


    AND spriden_pidm = rcresar_pidm

    AND rcrapp1_pidm = rcresar_pidm


    AND spriden_change_ind IS NULL

    ORDER BY name


    The second case statement is where I don't know exactly what it takes to get what I want.

    Output should be like:
    spriden_pidm name ID acg_elig_comm_code comm_code_description
    «0000000000', ' 1111111111 ","John Doe","268", «rigorous HS race"»

    If I take the second case statement it works great except that I do not have my comm_code description column. My question is how can I use my first statement value box to determine this column? I think that I need a case statement as I have, but I don't know how to reference the value of acg_elig_comm_code. Any help would be greatly appreciated. Thank you.

    Published by: blackhole82 on January 20, 2009 09:20

    Hello

    You cannot use the alias column in the query, even where it is set (except in the ORDER BY clause).
    You can set the alias in a subquery and then use it in a great query, like this:

    WITH  sub_q  AS
    (
        SELECT DISTINCT spriden_pidm,spriden_id id, spriden_last_name||', '||spriden_first_name name,
            CASE
                WHEN rcresar_comm_code_01 IN ('268','269','270') THEN rcresar_comm_code_01
                WHEN rcresar_comm_code_02 IN ('268','269','270') THEN rcresar_comm_code_02
                WHEN rcresar_comm_code_03 IN ('268','269','270') THEN rcresar_comm_code_03
                WHEN rcresar_comm_code_04 IN ('268','269','270') THEN rcresar_comm_code_04
                WHEN rcresar_comm_code_05 IN ('268','269','270') THEN rcresar_comm_code_05
                WHEN rcresar_comm_code_06 IN ('268','269','270') THEN rcresar_comm_code_06
                WHEN rcresar_comm_code_07 IN ('268','269','270') THEN rcresar_comm_code_07
                WHEN rcresar_comm_code_08 IN ('268','269','270') THEN rcresar_comm_code_08
                WHEN rcresar_comm_code_09 IN ('268','269','270') THEN rcresar_comm_code_09
                WHEN rcresar_comm_code_10 IN ('268','269','270') THEN rcresar_comm_code_10
            END acg_elig_comm_code   -- Originally posted with , here (error)
        FROM spriden, rcresar, rcrapp1
        WHERE (rcresar_comm_code_01 IN ('268','269','270')
                OR rcresar_comm_code_02 IN ('268','269','270')
                OR rcresar_comm_code_03 IN ('268','269','270')
                OR rcresar_comm_code_04 IN ('268','269','270')
                OR rcresar_comm_code_05 IN ('268','269','270')
                OR rcresar_comm_code_06 IN ('268','269','270')
                OR rcresar_comm_code_07 IN ('268','269','270')
                OR rcresar_comm_code_08 IN ('268','269','270')
                OR rcresar_comm_code_09 IN ('268','269','270')
                OR rcresar_comm_code_10 IN ('268','269','270'))
        AND rcresar_aidy_code = &aidy_code
        AND rcrapp1_aidy_code = rcresar_aidy_code
        AND rcrapp1_curr_rec_ind = 'Y'
        AND rcrapp1_seq_no = rcresar_seq_no
        AND spriden_pidm = rcresar_pidm
        AND rcrapp1_pidm = rcresar_pidm
        AND spriden_change_ind IS NULL
    )
    SELECT    sub_q.*,
              CASE
                  WHEN acg_elig_comm_code = '268' THEN 'Rigorous HS course'
                  WHEN acg_elig_comm_code = '269' THEN '2 or more AP or IB'
                  WHEN acg_elig_comm_code = '270' THEN 'ACG possible'
              END comm_code_description
    FROM      sub_q
    ORDER BY  name
    

    Furthermore, you might think to rearrange your table, so that you do not have 10 columns (rcresar_comm_code_01, rcresar_comm_code_02,...) that essentially do the same thing. The usual way to handle this kind of one-to-many relationship is to have all rcresar_comm_codes in a separate table, one per line, with a pointer to the table where you have them now.

    Published by: Frank Kulash, January 20, 2009 11:35
    Syntax error has been corrected

  • Need help with query SQL Inline views + Group

    Hello gurus,

    I would really appreciate your time and effort on this application. I have the following data set.

    Reference_No---Check_Number---Check_Date---description---Invoice_Number---Invoice_Type---Paid_Amount---Vendor_Number
    1234567 11223 - 05/07/2008 -paid for cleaning- 44345563-I-* 20.00 *---19
    1234567 11223 - 05/07/2008 - 44345563 -a--10,00---19 ofbad quality adjustment
    7654321 11223 - 05/07/2008 - setting the last billing cycle - 23543556 - A - 50.00 - 19
    4653456 11223 - 05/07/2008 - paid for cleaning - 35654765 - I - 30, 00-19

    Please ignore '-' added for clarity

    I'm writing a paid_amount based on Reference_No, Check_Number, Payment_Date, Invoice_Number, aggregate query Invoice_Type, Vendor_Number and display description with Invoice_type 'I' when there are multiple records with the same Reference_No, Check_Number, Payment_Date, Invoice_Type, Invoice_Number, Vendor_Number. When there are no more records I want to display the respective Description.

    The query should return the following data set

    Reference_No---Check_Number---Check_Date---description---Invoice_Number---Invoice_Type---Paid_Amount---Vendor_Number
    1234567 11223 - 05/07/2008 -paid for cleaning- 44345563-I-* 10.00 *---19
    7654321 11223 - 05/07/2008 - setting the last billing cycle - 23543556 - A - 50.00 - 19
    4653456 11223 - 05/07/2008 - paid for cleaning - 35654765 - I - 30, 00-19
    Here's my query. I'm a little lost.

    Select b., A.sequence_id, A.check_date, A.check_number, A.invoice_number, A.amount, A.vendor_number
    de)
    Select sequence_id, check_number, check_date, invoice_number, sum (paid_amount) sum, vendor_number
    of the INVOICE
    Sequence_id group check_date, check_number, invoice_number, vendor_number
    ) A, B OF INVOICE
    where A.sequence_id = B.sequence_id


    Thank you
    Nick

    It seems that this is a duplicate thread - correct me if I am wrong in this case->

    Need help with query SQL Inline views + Group

    Kind regards.

    LOULOU.

  • HELP required on forming the matrix of data using PL/SQL

    Hi all

    I'm new on this thread and need your help in this regard.

    I have a requirement for the construction of a matrix of 5000 X 5000 using PL/SQL. My original data tables have 5000 lines each and I need to make a correlation analysis using these data and need to store in a physical table, and not in memory. This feat feasible the simple use of PL/SQL? I understand that Oracle DB has a limit of 1000 columns (but not sure) and so I would like to know if there is a workaround for this kind of scenario. If not, what are the other alternative methods to achieve this feat? Do I need to use any 3rd party tools to do this? A quick response from experts is highly appreciated.

    Thanking you in advance all the gurus.

    Rgds

    SAI

    1006089 wrote:

    I have a requirement for the construction of a matrix of 5000 X 5000 using PL/SQL.

    Possible. But this will require a large part of the memory. As PL/SQL is a language server side, this means the server's memory. That means server potential resource problems.

    And that the server environment is a multiprocessu multi-user environment, it also means potentially several copies of this code of matrix running multiple processes, each putting a request very heavy on the resources of the server. Is no longer a matter of potential server resources, but a guarantee... (exactly the same problem if you use app server architecture and Java or .net)

    You have to ask what is the cracking of data, server-side language? The answer is SQL. No PL/SQL. SQL runs rings around PL/SQL, Java, C/C++ and other languages when it comes to complex, fast and scalable, processing of large volumes of data.

    So you ask yourself why use PL/SQL? With his expensive server memory footprint? SQL and not SQL tables that are designed to deal with massive data effectively and efficiently?

Maybe you are looking for

  • Broken covers lock on Satellite A200-1AD

    Hello My locking of the cover of my Satellite A200-1AD is broken.Now, I have to use a credit card to open the screen.Anyone know where I can get a new one? I bought the laptop in August 2007 with 1 year warranty. Greetz

  • Cannot find drivers for Toshiba Satellite A665-S6094

    Let me start from the beginning, I had a virus because im a chronic Downloader and had to wipe my hard drive. I burned a cd of installation of windows 7 because I have the key of windows 7 on the bottom of my laptop. At the end of the windows 7 insta

  • Windows update fails 0 x 80246008

    updates continue to fail with this error: 0 x 80246008.  I have tried both method 1 and 2 to fix this problem... I'm still not able to download updates windows on the site. What can I do else?

  • even another area office

    Is it possible to have a PC to connect to different areas, who would be chosen to logon. but have the same show desktop with each domain name.

  • Trouble installing Acrobat Reader DC

    We tried several times to download and install the update Adober reader. While we can go step of Adobe and connect to our account, when we get to the password in the Setup program, our password is not recognized. We continue to loop back to download