Two queries LOV in a point... is that possible?

Hello

I created a list of value form DML as below-

Select pcrs.cost_record_status, pcrs.port_cost_record_status_id
of ptcs_cost_record_status RFT

But, depends on "pcrs.port_cost_record_status_id" I want only certain values to display in the list.

For example:
-If pcrs.port_cost_record_status_id 2
- then view the State 2,3,4

Select pcrs.cost_record_status, pcrs.port_cost_record_status_id
of ptcs_cost_record_status RFT
where pcrs.port_cost_record_status_id in (2,3,4)

-If the State id is 1
-can view the status of 1.5

Select pcrs.cost_record_status, pcrs.port_cost_record_status_id
of ptcs_cost_record_status RFT
where pcrs.port_cost_record_status_id in (1.5)

Any ideas on how I can have two different LOV in one?

Thank you!!
Ling

LC says:
Hello

port_cost_record_status_id is a COMPONENT and it is retrieved from the database when the form is opened.

It doesn't look like one (the convention is that page elements are prefixed with their page number and referred to as bind variables using the ":").

Regarding the original question, which precedes the LOV query is:

select pcrs.cost_record_status, pcrs.port_cost_record_status_id
from ptcs_cost_record_status pcrs
where pcrs.port_cost_record_status_id in (2,3,4)
and :p1_port_cost_record_status_id = 2
union all
select pcrs.cost_record_status, pcrs.port_cost_record_status_id
from ptcs_cost_record_status pcrs
where pcrs.port_cost_record_status_id in (1,5)
and :p1_port_cost_record_status_id = 1

Tags: Database

Similar Questions

  • Want to combine the two queries

    Hello

    It is my first post here, I hope it's a good place to put it.

    I have two queries that both gave me the results. I guess that both are way more elegant or better to do what they do, but that's what I came with. So feel free to modify them. However, my real problem is I want to combine these two queries in a single query, removing duplicate information.

    analytical_query

    SELECT * from(
      select
      requisitions.acc_id AS "Accession #"
      ,requisitions.draw_date AS "Draw Date"
      ,requisitions.received_date AS "Received Date"
      ,req_panels.run_date AS "Run Date"
      ,tests.TEST_ID
      ,(CASE WHEN tests.TEST_ID IN (7101) THEN results.RESULT_NUMERIC*2
             ELSE results.RESULT_NUMERIC
       END) AS RESULT_NUMERIC
      ,doctors.f_name || ' '|| doctors.l_name AS "Physician"
      ,organizations.state AS "State"
    FROM requisitions
    
    inner join req_panels ON requisitions.acc_id = req_panels.acc_id
    inner join results ON req_panels.rp_id = results.rp_id
    inner join tests ON results.test_id = tests.test_id
    inner join doctors ON requisitions.doc_id1 = doctors.doc_id
    inner join organizations ON requisitions.org_id = organizations.org_id
    
    WHERE requisitions.DEL_FLAG='F'
         AND req_panels.DEL_FLAG='F'
         AND results.DEL_FLAG='F'
         AND req_panels.PANEL_ID IN (7000,70001,70551)
         AND results.TEST_ID IN (7101,7102,7107,7108)
         AND requisitions.RECEIVED_DATE > TO_DATE('9/1/2013', 'MM/DD/YYYY')
    ORDER BY requisitions.ACC_ID
    )
    
    pivot(
          MAX(RESULT_NUMERIC)
          for TEST_ID IN ('7101' AS CRP,'7102' AS Hemoglobin,'7107' AS "LDT Run 1",'7108' AS "LDT RUN 2")
    )
    

    culture_query

    SELECT * from(
    select
      requisitions.acc_id AS "Accession #"
      ,MAX(requisitions.draw_date) AS "Draw Date"
      ,MAX(requisitions.received_date) AS "Received Date"
      ,MAX(req_panels.run_date) AS "Run Date"
      ,tests.TEST_ID
      ,LISTAGG(results.RESULT_ALPHA, ';')
      WITHIN GROUP
      (ORDER BY results.RESULT_ALPHA) RESULT_ALPHA
    FROM requisitions
    
    inner join req_panels ON requisitions.acc_id = req_panels.acc_id
    inner join results ON req_panels.rp_id = results.rp_id
    inner join tests ON results.test_id = tests.test_id
    inner join doctors ON requisitions.doc_id1 = doctors.doc_id
    inner join organizations ON requisitions.org_id = organizations.org_id
    
    WHERE req_panels.PANEL_ID IN (7000,70001,70551)
         AND results.TEST_ID IN (10010,10052,11010)
         AND requisitions.RECEIVED_DATE > TO_DATE('9/1/2013', 'MM/DD/YYYY')
         AND requisitions.DEL_FLAG = 'F'
         AND req_panels.DEL_FLAG = 'F'
         AND results.DEL_FLAG = 'F'
         AND req_panels.RUN_DATE is not null
    group by requisitions.ACC_ID, tests.TEST_ID
    )
    
    pivot(
          MAX(RESULT_ALPHA)
          for TEST_ID IN ('10010' AS "Organism",'10052' AS "Negative/No Growth", '11010' AS "Growth")
    )
    

    Basically, what is missing from the first query is the global list of the 'RESULT_ALPHA' for 'TEST_ID"10010, 10052 and 11010 numbers. And because of the way they want to view this information that I had to tilt it, which is where I ran into problems. If anyone has any idea on how I can combine these two requests and make them more effective that would be great.

    Thank you.

    Hello

    JayG30 wrote:

    ... I have however found a way to do what I would call "swivel conditional."  ...

    I think it's the crux of this problem; you want MAX BOF a few tests and LISTAGG for others.  I don't know a good way to attract the SELECT... PIVOT to do both at the same time.  I think it's one of those situations where SOME... PIVOT is not the best tool for the job;  MAX (CASE...) and LISTAGG (CASE...) may be more practical and more effective:

    SELECT rq.acc_id

    , MAX (rq.draw_date) AS "the draw Date.

    , MAX (rq.received_date) as BEING "received Date".

    , MAX (rp.run_date) AS "Date of the race.

    , MAX (CASE WHEN rs.test_id = 7101 THEN rs.result_numeric * END 2) AS the crp

    , MAX (CASE WHEN rs.test_id = 7102 THEN rs.result_numeric END) AS hemoglobin

    , MAX (CASE WHEN rs.test_id = 7107 THEN rs.result_numeric END) AS "LDT Run 1.

    , MAX (CASE WHEN rs.test_id = 7108 THEN rs.result_numeric END) AS "LDT, 2nd round.

    , LISTAGG (CASE WHEN rs.test_id = 10010 THEN rs.result_alpha END)

    , ';'

    ) Within GROUP (ORDER BY rs.result_alpha) AS "organization".

    , LISTAGG (CASE WHEN rs.test_id = 11010 THEN rs.result_alpha END)

    , ';'

    ) Within GROUP (ORDER BY rs.result_alpha) AS a 'growth '.

    , LISTAGG (CASE WHEN rs.test_id = 10052 THEN rs.result_alpha END)

    , ';'

    ) Within GROUP (ORDER BY rs.result_alpha) AS 'Negative/No growth '.

    Rq requisitions

    INNER JOIN req_panels ON rp.acc_id = rq.acc_id PR

    INNER JOIN results rs ON rs.rp_id = rp.rp_id

    WHERE rq.del_flag = 'F'

    AND rp.del_flag = 'F'

    AND rs.del_flag = 'F'

    AND rp.run_date IS NOT NULL

    GROUP BY rq.acc_id

    ORDER BY rq.acc_id

    ;

    I don't quite get the results you have posted; for example, I don't see how you get a row of results with 'Accession' = 142425, while acc_id does not occur in the sample data.  It was maybe just a typo.

  • Help to combine the two queries with dependencies

    Combining two queries with dependencies:
    First ask: Returns USER_ID that has a type of access to a table with the OWNER (I also shoot the TLA of the USER_ID standard: ' of TLA #)

    Select distinct SUBSTR (DBA_USERS. Username, 2, 3) AS TLA

    DBA_USERS. Username USED_ID

    DBA_TAB_PRIVS. Owner OWNER

    from DBA_USERS

    DBA_ROLE_PRIVS

    DBA_TAB_PRIVS

    where DBA_USERS. Username = DBA_ROLE_PRIVS. Dealer

    and DBA_USERS.default_tablespace not in ('SYSTEM', "SYSAUX")

    and DBA_USERS. Username like would be %'

    and DBA_ROLE_PRIVS. Granted_role = DBA_TAB_PRIVS. Dealer

    and SUBSTR (DBA_USERS. Username, 2, 3) <>DBA_TAB_PRIVS. Owner

    ;

    Example of results (red font used in the last citation):

    TLA USED_ID OWNER

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

    DGTX999 GTX GRR

    DGTX999 GTX ABG

    DGTX999 GTX HTC

    FWS DFWS999 GRR

    OCN DOCN999 GRR

    RHR DRHR999 DAS

    ETM DETM999 DAS

    FWS DFWS995 DAS

    CD DCDS999 DAS

    ABE DABE999 DAS



    Second request: matches the USER name (same standards as above) and MACHINES (filter PC connections) and the number of connections made of

    Select DBA_USERS. Username

    DBA_HIST_ACTIVE_SESS_HISTORY. Machine

    COUNT (*) AS CONN_COUNT

    of DBA_HIST_ACTIVE_SESS_HISTORY

    DBA_USERS

    where DBA_HIST_ACTIVE_SESS_HISTORY. User_id = DBA_USERS. User_id

    and DBA_USERS. Username like would be %'

    and DBA_HIST_ACTIVE_SESS_HISTORY. Machine not as "WINAD%\%-%".

    Group of DBA_USERS. Username

    DBA_HIST_ACTIVE_SESS_HISTORY. Machine

    order by 1

    3 desc;

    Example of results (red font used in the last citation):

    MACHINE CONN_COUNT USERNAME

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

    DFWS999 home13e0 7557

    DGAM800 vu1246 37

    DGAM999 vu1246 2558

    DABE999 back18cb 4639

    DINL888 home162f 84

    DFWS999 WINDAD\OMHQ58BF 178

    DCDS999 back18cb 788

    DGTX999 home18c8 7

    DGTX999 home13d3 62

    DOCN999 vu1261 44

    DFWS999 back1976 3

    DCDS999 home18c8 173

    DGTX999 home19c9 13

    What I'd like to have (just made two first USER_IDs from the first query) (COL duplicated for each separate owner 1-4).  So 3 machines and 3 owners would result in 9 lines (I could reorganize the collar and use a 'pause'):

    TLA USED_ID MACHINE CONN_COUNT OWNER

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

    GTX DGTX999 home13d3 62 GRR

    Home18c8 GTX DGTX999 7 GRR

    DGTX999 GTX home19c9 GRR 6

    GTX DGTX999 home13d3 62 ABG

    DGTX999 GTX home18c8 ABG 7

    DGTX999 GTX home19c9 6 GBS

    GTX DGTX999 home13d3 62 CTH

    DGTX999 GTX HTC 7 home18c8

    DGTX999 GTX home19c9 6 HTC

    FWS DFWS999 home13e0 7557 GRR

    FWS DFWS999 WINDAD\OMHQ58BF 178 GRR

    FWS DFWS999 back1976 GRR 3


    So it would be logically read: TLA as USER_ID of MACHINE, CONN_COUNT consultation times: OWNER information.

    Thought as only those with the necessary values. Just try this and let me know in the case of all conflicts in the output.

    WITH T1 AS)

    Select distinct SUBSTR (DBA_USERS. Username, 2, 3) AS TLA

    DBA_USERS. Username USED_ID

    DBA_TAB_PRIVS. Owner OWNER

    ROWNUM RN

    from DBA_USERS

    DBA_ROLE_PRIVS

    DBA_TAB_PRIVS

    where DBA_USERS. Username = DBA_ROLE_PRIVS. Dealer

    and DBA_USERS.default_tablespace not in ('SYSTEM', "SYSAUX")

    and DBA_USERS. Username like would be %'

    and DBA_ROLE_PRIVS. Granted_role = DBA_TAB_PRIVS. Dealer

    and SUBSTR (DBA_USERS. Username, 2, 3) <> DBA_TAB_PRIVS. Owner),

    () AS T2

    Select DBA_USERS. Username

    DBA_HIST_ACTIVE_SESS_HISTORY. Machine

    COUNT (*) AS CONN_COUNT

    of DBA_HIST_ACTIVE_SESS_HISTORY

    DBA_USERS

    where DBA_HIST_ACTIVE_SESS_HISTORY. User_id = DBA_USERS. User_id

    and DBA_USERS. Username like would be %'

    and DBA_HIST_ACTIVE_SESS_HISTORY. Machine not as "WINAD%\%-%".

    Group of DBA_USERS. Username

    DBA_HIST_ACTIVE_SESS_HISTORY. Machine

    order by 1

    3 desc)

    SELECT T1. TLA

    ,         T1. USED_ID

    ,         T2. MACHINE

    ,         T2. CONN_COUNT

    ,         T1. OWNER

    FROM T1

    T2

    WHERE T1. USED_ID = T2. USER NAME;

  • two queries against aud$ with different results

    Hi guys

    I'm not so good with queries and it is the reason for my question:

    We have active audit and we want to get the following information (monthly):

    1. -How many times the logon user to the database.
    2. -each logon to each user in a month.

    For the first (1) obligation for us to have the following query:

    select USERID "Cuenta", USERHOST, TERMINAL, nombres||' '||PRIMER_APELLIDO||' '||SEGUNDO_APELLIDO "WhiteList"
    , count(*) "TOTAL"
    from aud$, ab.usuarios
    where (ACTION# = 100) and 
    (NTIMESTAMP# between (to_date(to_char('01092013 00:00:00'),'ddmmyyyy HH24:MI:SS'))
        and (to_date(to_char('30092013 23:59:00'),'ddmmyyyy HH24:MI:SS'))) and
    USERID = CODIGO_USUARIO(+) and
    USERID not in ('DBSNMP','SYSMAN')
    group by USERID, USERHOST, TERMINAL,  nombres||' '||PRIMER_APELLIDO||' '||SEGUNDO_APELLIDO
    order by USERID, USERHOST, TERMINAL;
    

    the result of this query shows like this:

    Header 1

    Cuenta USERHOST TERMINAL WhiteList TOTAL

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

    ASEGUR MAQUINADIAB\SSSSS IUOOO PEPITO GARCIA GARCIA Y SOCIED 10

    ASEGUR POSADASDE\MNNN4550094 MNNN4550094 PEPITO GARCIA GARCIA Y SOCIED 1

    ASEGUR POSADASDE\YUMI YUMI PEPITO GARCIA GARCIA Y SOCIED 10

    ASEGUR YUH PEPITO GARCIA GARCIA Y SOCIED 20

    ASEGUR SDFRG PEPITO GARCIA GARCIA Y SOCIED 13

    ASEGUR signy PEPITO GARCIA Y GARCIA SOCIED 29

    Sigurd ASEGUR PEPITO GARCIA Y GARCIA SOCIED 32

    ASEGUR valhalla-Legacy PEPITO GARCIA Y GARCIA SOCIED 12

    ADMIN MAQUINADIAB\SSSSS IUOOO USER ADMINISTRATOR NETWORKING 3

    SPRINGUSR            bragi                                                                                      98

    SPRINGUSR            hermod                                                                                     59

    SPRINGUSR            YUH                                                                                        49

    Therefore, total logons per month per user.

    for the second requirement, we use the tracking query:

    select USERID "Cuenta", USERHOST, TERMINAL, to_char(NTIMESTAMP#,'YYYYMMDD HH24:MI:SS') "Fec Ing", nombres||' '||PRIMER_APELLIDO||' '||SEGUNDO_APELLIDO "WhiteList"
    --, count(*) "TOTAL"
    from aud$, ab.usuarios
    where (ACTION# = 100) and 
    --to_char(NTIMESTAMP#,'dd-mm-yy')=to_char(sysdate-50,'dd-mm-yy') and 
    (NTIMESTAMP# between (to_date(to_char('01062013 18:00:00'),'ddmmyyyy HH24:MI:SS'))
        and (to_date(to_char('30062013 23:59:00'),'ddmmyyyy HH24:MI:SS'))) and
    USERID = CODIGO_USUARIO(+) and
    USERID not in ('DBSNMP','SYSMAN')
    group by USERID, USERHOST, TERMINAL,to_char(NTIMESTAMP#,'YYYYMMDD HH24:MI:SS'), nombres||' '||PRIMER_APELLIDO||' '||SEGUNDO_APELLIDO
    order by USERID, USERHOST, TERMINAL;
    

    Header 1

    Cuenta USERHOST Fec TERMINAL Ing white list

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

    UTILISATEUR12 DOMINIODDD\IOIPOP IOIPOP 20130930 12:08:33 ANGEL ROBERTO GARCIA Y GARCIA S

    UTILISATEUR12 DOMINIODDD\IOIPOP IOIPOP 20130930 14:28:47 ANGEL ROBERTO GARCIA Y GARCIA S

    UTILISATEUR12 DOMINIODDD\IOIPOP IOIPOP 20130930 16:24:43 ANGEL ROBERTO GARCIA Y GARCIA S

    Thus, shows the opening of each session conducted per user per month.

    But in the two queries, the results are different. This is not to assume that they must have the same number of logons?

    I mean, if I have summarized the numbers in the TOTAL column I less that I get in the second query. Always!

    could you help us?

    Thank you

    Hello

    Why you use GROUP BY in the second query, remove it from the second query, then result will be the same

    HTH

  • How to combine the two queries into a single

    Hi gurus,

    SQL > select * from v version $;

    BANNER

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

    Oracle Database 10g Release 10.2.0.4.0 - Production 64-bit

    PL/SQL Release 10.2.0.4.0 - Production

    CORE 10.2.0.4.0 Production

    AMT for Linux: release 10.2.0.4.0 - Production

    NLSRTL Version 10.2.0.4.0 - Production

    SQL >

    I have following two queries. How can I convert these two queries into one with the same result?

    1ST QUARTER

    SELECT id, $vdate, SupplierName, venddate, vid

    THE SELLER

    WHERE processid = 32

    AND venddate is null

    AND vid to (select vid from view_vid where type = 'PDX')

    AND (id, $vdate) not in (select id, $vdate from vkfl_is where task_id = 55)

    AND (id, $vdate) in (select id, vidate from market_data where marketed_date is null)

    AND id not in (select id from location)

    Q2

    SELECT id, $vdate, SupplierName, venddate, vid

    THE SELLER

    WHERE processid = 20

    AND venddate is null

    AND vid to (select vid from view_vid where type = 'PBX')

    AND (id, $vdate) not in (select id, $vdate from vkfl_is where task_id = 40)

    AND (id, $vdate) in (select id, vidate from market_data where region_date is null)

    AND id not in (select id from location)

    I can the UNION queries these two, but is there some way I can write a single query that gives me the same result as above two queries?

    Any help would be much appreciated

    Thanks in advance

    Sorry, it lack

    SELECT id, $vdate, SupplierName, venddate, vid

    THE SELLER

    ProcessID WHERE in (32.20)

    AND venddate is null

    AND vid to (select vid from view_vid where type = case when processid = 32

    then "PDX".

    else "PBX".

    end)

    AND (id, $vdate) not in (select id, $vdate from vkfl_is where task_id = case when processid = 32

    then 55

    40 else

    end)

    AND (id, $vdate) in (select id, vidate from market_data cases where processid = 32)

    then marketed_date

    of other region_date

    end to the null value

    )

    AND id not in (select id from location)

    Concerning

    Etbin

  • Any difference between the two queries

    Hello

    Could someone please help me to see if the following two queries return different results?

    Thank you

    Query A

    SELECT A.BATCH_NO,

    A.BU_CODE,

    SUM (A.AMOUNT) AMOUNT

    FROM TABLE_A HAS

    WHERE A.BU_CODE = 20

    AND G_DATE BETWEEN TO_DATE (JANUARY 31, 2013 ',' MON-DD-YYYY "")

    AND TO_DATE (MARCH 31, 2013 ',' MON-DD-YYYY "")

    --

    AND A.BATCH_NO IN (SELECT BATCH_NO

    TABLE_A B1

    WHERE B1. BATCH_NO = A.BATCH_NO

    AND B1. BU_CODE = A.BU_CODE

    AND B1. ' CODE_P = ' 06-01-01-000.

    AND B1. FROM_FLAG = 'FROM '.

    )

    AND A.BATCH_NO IN (SELECT BATCH_NO

    FROM TABLE_A B

    WHERE B.BATCH_NO = A.BATCH_NO

    AND B.BU_CODE = A.BU_CODE

    AND B1.ORG = '10'

    )

    A.BATCH_NO GROUP,

    A.BU_CODE

    ;

    Query B

    SELECT A.BATCH_NO,

    A.BU_CODE,

    SUM (A.AMOUNT) AMOUNT

    FROM TABLE_A HAS

    WHERE A.BU_CODE = 20

    AND G_DATE BETWEEN TO_DATE (JANUARY 31, 2013 ',' MON-DD-YYYY "")

    AND TO_DATE (MARCH 31, 2013 ',' MON-DD-YYYY "")

    --

    AND A.BATCH_NO IN (SELECT BATCH_NO

    TABLE_A B1

    WHERE B1. BATCH_NO = A.BATCH_NO

    AND B1. BU_CODE = A.BU_CODE

    AND B1. ' CODE_P = ' 06-01-01-000.

    AND B1. FROM_FLAG = 'FROM '.

    AND B1.ORG = '10'

    )

    A.BATCH_NO GROUP,

    A.BU_CODE

    ;

    Hello

    These 2 requests are not the same.  Depending on your data, query A, can select more lines as searching for B.

    I do not have access to your table, so I'll give an example of using the table scott.emp.

    The following 2 queries look like your 2 questions:

    SELECT deptno - query A
    work
    sal
    FROM scott.emp m
    WHERE deptno IN ((in English only)
    SELECT sj.deptno
    FROM scott.emp sj
    WHERE sj.deptno = m.deptno
    AND sj.job = 'CLERK '.
    )
    AND (IN) deptno
    SELECT ss.deptno
    FROM scott.emp ss
    WHERE ss.deptno = m.deptno
    AND ss.sal > 1200
    )
    ;

    SELECT deptno - query B
    work
    sal
    FROM scott.emp m
    WHERE deptno IN ((in English only)
    SELECT s.deptno
    FROM scott.emp s
    WHERE s.deptno = m.deptno
    AND s.job = 'CLERK '.
    AND s.sal > 1200
    )
    ;

    The results of A query are all 14 rows in the table, but query B produces only 3 lines of deptno = 10.

    Query A looking for departments who have committed and the departments that have sal > 1200.  If a line in the Department has job = 'CLERK' (regardless of the sal), and another line was sal > 1200 (regardless of the work), while the Department meets both criteria.

    Query B is looking for federal departments who have committed that sal is over 1200.  Two criteria must be met on the same line.

  • Plan of the hash value for two queries!

    Hello
    DB: Oracle 11g (11.2.0.3.0)
    OS: RHEL 5

    I have two question:

    1. can two queries have the same hash value of the plan? I mean I have here are two queries:

    SELECT /+ NO_MERGE * / MIN (payor.next_review_date). *
    * Payer from *.
    * WHERE payor.review_complete = 0 *.
    * AND payor.closing_date IS NULL *.
    * AND payor.patient_key = 10; *

    and

    SELECT MIN (payor.next_review_date)
    * Payer from *.
    * WHERE payor.review_complete = 0 *.
    * AND payor.closing_date IS NULL *.
    * AND payor.patient_key = 10; *

    When I tried to examine the execution plan for the two motions, the hash value of the plan remains the same. This means that implementation plan for both queries are same? If so, then how Oracle includes or changes to the execution plan based on hint. If not, then what hash value of the plan represents?

    2. If the plan with suspicion, and without suspicion is identical except for a given query except the number of lines and bytes. Do you mean this query with fewer lines and scanned bytes is better?

    Thanks in advance
    -Onkar

    >
    1. can two queries have the same hash value of the plan?
    >
    Yes - as already said - but it's not just because of tips.

    Here is the example code that I use to show that Oracle does NOT simply use a text version of the query that you propose and compute a hash of it.
    These two queries are radically different but have the same hash value; Oracle are not different at all.

    set serveroutput on
    set autotrace traceonly
    select * from DEPT A, EMP B
    where A.DEPTNO=B.DEPTNO
    
    SQL> select * from DEPT A, EMP B
      2  where A.DEPTNO=B.DEPTNO
      3  / 
    
    14 rows selected.
    
    Execution Plan
    ----------------------------------------------------------
    Plan hash value: 844388907
    
    select * from
    (select * from DEPT) A, (select * from EMP) B
    WHERE A.DEPTNO = B.DEPTNO
    
    SQL> select * from
      2  (select * from DEPT) A, (select * from EMP) B
      3  WHERE A.DEPTNO = B.DEPTNO
      4  / 
    
    14 rows selected.
    
    Execution Plan
    ----------------------------------------------------------
    Plan hash value: 844388907
    
  • MERGE TWO QUERIES...

    Hi all

    I have two queries like this...

    I want to have a single query of the two tables satisfying condition where that show all RELATIONSHIP, FILED_NAME, P2. ATTRIBUTE, P3. ATTRIBUTE, DESCRIPTION of the AREA, the two SOURCE tables P3 AND P2.

    Appreciate your help.

    Thank you/kumar

    Published by: kumar73 on May 28, 2010 09:49

    Hope you have understood my requirement.

    Ah, I see now that I misread your question (it must be a 'weekend-thing' ;)).

    Try something like this:

    select p3.relation
    ,      p3.field_name
    ,      p2.attribute
    ,      p3.attribute
    ,      p3.value_description
    ,      p3.source
    from ( select relation, field_name, attribute, field_description, source
           from p3i2009q2_variable_info p3
          where relation not in
                ('CHAI', 'ITAB', 'ITB2', 'ITB3', 'MINI', 'NOTE', 'MINC', 'FINI',
                 'FTIM', 'FWTG', 'FMLY', 'FMIS', 'FSUM', 'MEMB', 'FINC', 'FASO')
            and (substr(field_name, -2) in
                ('X1', 'X2', 'X3', 'X4', 'X5', 'X0', 'XA', 'XB', 'XM', 'XP', 'CM', 'MT') or
                substr(field_name, -1) in ('X') or substr(field_name, 1) in ('J'))
            and (attribute like 'NUM%' or attribute = '-')
         ) p3
    ,    ( select relation, field_name, attribute, field_description, source
           from p2i2009m04_variable_info p2
          where relation not in
                ('CHAI', 'ITAB', 'ITB2', 'ITB3', 'MINI', 'NOTE', 'MINC', 'FINI',
                 'FTIM', 'FWTG', 'FMLY', 'FMIS', 'FSUM', 'MEMB', 'FINC', 'FASO')
            and (substr(field_name, -2) in
                ('X1', 'X2', 'X3', 'X4', 'X5', 'X0', 'XA', 'XB', 'XM', 'XP', 'CM', 'MT') or
                substr(field_name, -1) in ('X') or substr(field_name, 1) in ('J'))
            and (attribute like 'NUM%' or attribute = '-')
         ) p2
    where p3.relation = p2.relation
    order by relation;
    

    You may need to adjust my untested example, for example you might need an outer join and/or add predicates more as you wish.

  • Why this two queries are not same

    Hi all

    Can you please explain this fundamental thing. Why this two queries are different. (10.2.0.3 Solaris Sparc 64)
    create table x1(a1 varchar2(10),a2 number, a3 varchar2(10));
    create table x2(b1 varchar2(10),b2 number, b3 varchar2(10));
    insert into x1 values('X101',1,'XX1');
    insert into x1 values('X101',1,'XX1');
    insert into x1 values('X102',1,'XX2');
    insert into x1 values('X103',2,'XX3');
    insert into x1 values('X104',2,'XX4');
    insert into x1 values('X105',3,'XX5');
    commit;
    
    insert into x2 values('X101',1,'X21');
    insert into x2 values('X101',1,'X21');
    insert into x2 values('X102',1,'X22');
    insert into x2 values('X103',2,'X23');
    insert into x2 values('X104',2,'X24');
    commit;
    
    WITH xx AS (select b1,b2 from x2 where b1 IS NULL)
     select x1.* from x1 ,  xx
      where x1.a1 = xx.b1(+) and  x1.a2 = xx.b2(+) ;
     
    A1                 A2 A3
    ---------- ---------- ----------
    X105                3 XX5
    X104                2 XX4
    X102                1 XX2
    X103                2 XX3
    X101                1 XX1
    X101                1 XX1
     
    6 rows selected
     
    select x1.* from x1, x2 where x1.a1 = x2.b1(+)
        and x1.a2 = x2.b2(+)  and x2.b1 IS NULL;
     
    A1                 A2 A3
    ---------- ---------- ----------
    X105                3 XX5
     
    select b1,b2 from x2 where b1 IS NULL;
     
    B1                 B2
    ---------- ----------
     

    Thank you!
    NA not (sentence of) think of this.
    + (it's one of those things that I really need of don't forget do not forget ;)) +)

    hoek&XE> select x1.*
      2  from   x1
      3  where not exists ( select null
      4                     from   x2
      5                     where  x1.a1 = x2.b1
      6                     and    x1.a2 = x2.b2
      7                    );
    
    A1                 A2 A3
    ---------- ---------- ----------
    X105                3 XX5
    
    1 rij is geselecteerd.
    
    Uitvoeringspan
    ----------------------------------------------------------
    Plan hash value: 816925353
    
    ---------------------------------------------------------------------------
    | Id  | Operation          | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    ---------------------------------------------------------------------------
    |   0 | SELECT STATEMENT   |      |     5 |   100 |     5  (20)| 00:00:01 |
    |*  1 |  HASH JOIN ANTI    |      |     5 |   100 |     5  (20)| 00:00:01 |
    |   2 |   TABLE ACCESS FULL| X1   |     6 |    72 |     2   (0)| 00:00:01 |
    |   3 |   TABLE ACCESS FULL| X2   |     5 |    40 |     2   (0)| 00:00:01 |
    ---------------------------------------------------------------------------
    
    Predicate Information (identified by operation id):
    ---------------------------------------------------
    
       1 - access("X1"."A1"="X2"."B1" AND "X1"."A2"="X2"."B2")
    
    Statistics
    ----------------------------------------------------------
              1  recursive calls
              0  db block gets
              6  consistent gets
              0  physical reads
              0  redo size
            518  bytes sent via SQL*Net to client
            384  bytes received via SQL*Net from client
              2  SQL*Net roundtrips to/from client
              0  sorts (memory)
              0  sorts (disk)
              1  rows processed
    
  • Try to combine the two queries

    I have two queries of tables in which I combine and summarize the results in a single value. Could someone let me know what it is that im missing here? Thank you

    Deanna

    Output current:

    SUM
    5
    10

    The output I want to see:
    SUM
    15


    My paintings:

    TABLE 'CHART '.
    CASE_NUMBER - VARCHAR2
    PER_INV_FATALITIES - NUMBER (5.0)
    ASSIGNEDDATE_CHART - DATE

    TABLE "VEHICLES".
    CASE_NUMBER - VARCHAR2
    VEHICLE_FATALITY #-NUMBER (5.0)



    Current SQL query:
    SELECT SUM(ct) FROM (
    SELECT SUM(vehicle_fatality#) ct FROM vehicles inner join chart
    on vehicles.case_number=chart.case_number
    WHERE vehicle_fatality#>=1 AND 
    ASSIGNEDDATE_CHART BETWEEN TO_CHAR(TRUNC(SYSDATE,'RR'),'DD/MON/RR')AND SYSDATE)
    union all
    SELECT SUM(ct) FROM (
    SELECT SUM(per_inv_fatalities) ct FROM chart
    WHERE PER_INV_FATALITIES>=1 AND 
    ASSIGNEDDATE_CHART BETWEEN TO_CHAR(TRUNC(SYSDATE,'RR'),'DD/MON/RR')AND SYSDATE);

    Hello

    Instead of:

    SELECT  SUM (ct)
    FROM     (query_a)
    UNION ALL
    SELECT  SUM (ct)
    FROM     (query_b)
    ;
    

    do

    SELECT     SUM (ct)
    FROM     (          query_a
         UNION ALL     query_b
         )
    ;
    

    SUM without GROUP BY will produce a line.
    If you do a UNION ALL of two queries of this type operation, you will get two rows.
    The UNION ALL first, then make a single SUM on the combined results.

  • outer join: difference between two queries

    Below two queries which should give the same results in my opinion. I want that all records of u_protocol and the pval.u_protocol_variable_value value if necessary.

    Why the outer join in query2 does not work as in query1?


    Query1:
    select p.u_protocol_id, i.u_protocol_variable_value
    from lims_sys.u_protocol p,
    (
       select pval.u_protocol_id, pval.u_protocol_variable_value
       from lims_sys.u_protocol_variable pvar, lims_sys.u_protocol_value_user pval
       where pvar.u_protocol_variable_id = pval.u_protocol_variable_id
       and pvar.name = 'VALUE_Protocol_Group'
    ) i   
    where p.u_protocol_id  = i.u_protocol_id (+)
    Query2:
    select prt.u_protocol_id, pval.u_protocol_variable_value
    from lims_sys.u_protocol prt, lims_sys.u_protocol_variable pvar, lims_sys.u_protocol_value_user pval
    where pvar.u_protocol_variable_id = pval.u_protocol_variable_id
    and prt.u_protocol_id = pval.u_protocol_id (+)
    and pvar.name = 'VALUE_Protocol_Group'

    Hello

    When you perform an outer join, all conditions on the tables in option must be outer join conditions. Otherwise, the effect is an inner join.
    There is one exception: cascade of outer joins, external-junction b of a and c is outside attached to b. In this case, in the b - c join only columns of c are marked with the sign +.

    Re - write to obtain the same results as query1, query2 like this:

    select  prt.u_protocol_id
    ,      pval.u_protocol_variable_value
    from     lims_sys.u_protocol          prt
    ,      lims_sys.u_protocol_variable     pvar
    ,      lims_sys.u_protocol_value_user pval
    where     pvar.u_protocol_variable_id (+)     = pval.u_protocol_variable_id     -- cascading outer join
    and     prt.u_protocol_id           = pval.u_protocol_id (+)
    and     pvar.name (+)               = 'VALUE_Protocol_Group'     -- (+) added
    ;
    

    I find the syntax ANSI easier to use for all the joins and much easier for outer joins.

  • compare the fields of two queries

    I need to compare the fields of two queries.

    I went through many articles to asktom help operator less. but I'm not convinced by this method.

    Comaprisons are for about 10 fields.

    So I'm planing to do using sliders and nested loops. performance can be a problem.

    Please give your suggestions or solutions.

    OK, using the data you provided, I get this:

    with map_test_fac as (select 100 idid, 789 ifid, 300 edid, 741 efid from dual union all
                          select 100 idid, 123 ifid, 300 edid, 963 efid from dual union all
                          select 100 idid, 456 ifid, 300 edid, 258 efid from dual),
             test_fac as (select 741 facid, 'ETY' type, 'EUR' ccy, 'Ext' src, 300 did from dual union all
                          select 789 facid, 'WE' type, 'EUR' ccy, 'Int' src, 100 did from dual union all
                          select 123 facid, 'VPR' type, 'EUR' ccy, 'Int' src, 100 did from dual union all
                          select 456 facid, 'ETY' type, 'USD' ccy, 'Int' src, 100 did from dual union all
                          select 963 facid, 'WE' type, 'EUR' ccy, 'Ext' src, 300 did from dual union all
                          select 258 facid, 'VPR' type, 'EUR' ccy, 'Ext' src, 300 did from dual)
    -- end of mimicking your data: USE SQL below:
    select tfi.facid int_facid,
           tfi.type int_type,
           tfi.ccy int_ccy,
           tfi.src int_src,
           tfi.did int_did,
           tfe.facid ext_facid,
           tfe.type ext_type,
           tfe.ccy ext_ccy,
           tfe.src ext_src,
           tfe.did ext_did
    from   test_fac tfi,
           test_fac tfe,
           map_test_fac mtf
    where  mtf.ifid = tfi.facid
    and    mtf.efid = tfe.facid
    and    mtf.idid = tfi.did
    and    mtf.edid = tfe.did
    and    (tfi.type != tfe.type
            or tfi.ccy != tfe.ccy)
    
     INT_FACID INT INT INT    INT_DID  EXT_FACID EXT EXT EXT    EXT_DID
    ---------- --- --- --- ---------- ---------- --- --- --- ----------
           789 WE  EUR Int        100        741 ETY EUR Ext        300
           123 VPR EUR Int        100        963 WE  EUR Ext        300
           456 ETY USD Int        100        258 VPR EUR Ext        300
    

    However, I think that your mapping data is incorrect, so with keys of information:

    with map_test_fac as (select 100 idid, 789 ifid, 300 edid, 963 efid from dual union all
                          select 100 idid, 123 ifid, 300 edid, 258 efid from dual union all
                          select 100 idid, 456 ifid, 300 edid, 741 efid from dual),
             test_fac as (select 741 facid, 'ETY' type, 'EUR' ccy, 'Ext' src, 300 did from dual union all
                          select 789 facid, 'WE' type, 'EUR' ccy, 'Int' src, 100 did from dual union all
                          select 123 facid, 'VPR' type, 'EUR' ccy, 'Int' src, 100 did from dual union all
                          select 456 facid, 'ETY' type, 'USD' ccy, 'Int' src, 100 did from dual union all
                          select 963 facid, 'WE' type, 'EUR' ccy, 'Ext' src, 300 did from dual union all
                          select 258 facid, 'VPR' type, 'EUR' ccy, 'Ext' src, 300 did from dual)
    -- end of mimicking your data: USE SQL below:
    select tfi.facid int_facid,
           tfi.type int_type,
           tfi.ccy int_ccy,
           tfi.src int_src,
           tfi.did int_did,
           tfe.facid ext_facid,
           tfe.type ext_type,
           tfe.ccy ext_ccy,
           tfe.src ext_src,
           tfe.did ext_did
    from   test_fac tfi,
           test_fac tfe,
           map_test_fac mtf
    where  mtf.ifid = tfi.facid
    and    mtf.efid = tfe.facid
    and    mtf.idid = tfi.did
    and    mtf.edid = tfe.did
    and    (tfi.type != tfe.type
            or tfi.ccy != tfe.ccy)
    
     INT_FACID INT INT INT    INT_DID  EXT_FACID EXT EXT EXT    EXT_DID
    ---------- --- --- --- ---------- ---------- --- --- --- ----------
           456 ETY USD Int        100        741 ETY EUR Ext        300
    

    That's more like what you're looking for?

  • Vuze download is very slow... He pointed out that I have a nat problem

    nat problem?

    Vuze download is very slow... He pointed out that I have a nat problem... Help please.?

    Hello

    ·        What browser do you use to access the internet?

    ·        What is the full error message that you receive?

    ·        Is it only when you download on Vuze?

    I suggest that temporarily disable you antivirus software and firewall installed on your computer and check to see if it helps:

    Disable the anti-virus software

    http://Windows.Microsoft.com/en-us/Windows-Vista/disable-antivirus-software

    Enable or disable Windows Firewall
     http://Windows.Microsoft.com/en-us/Windows-Vista/turn-Windows-Firewall-on-or-off

    Note: disabling anti-virus or Windows Firewall can make your computer (and your network, if you have one) more vulnerable to damage caused by worms or hackers.

    You can also post your query on Vuze forum to get help:

    http://Forum.Vuze.com/index.jspa

  • combine the two queries analysis

    Hi friends,

    could you please help me to combine these two queries. The bottom one looks like, take too many resources.

    FUNCTION XML_error_log ()P_i_xml IN XMLTYPE, p_i_event_key IN VARCHAR2,( )

    RETURN VARCHAR2

    IS

    l_covered_product_header_id NUMBER ;

    l_item_path VARCHAR2 (500);

       xml_table                     XMLTYPE;

    p_ret_code_o VARCHAR2 (5);

    p_error_buff_o VARCHAR2 (2000);

       l_user_id                     NUMBER (15) := fnd_global . user_id ;

    l_implicit_product_name VARCHAR2 (40);

    l_top_model_line_id oe_order_lines_all . top_model_line_id % TYPE;

    main_error_check VARCHAR2 (100) := NULL;

    main_error_check1 VARCHAR2 (100) := NULL;

    l_status_log_status VARCHAR2 (1);

    l_err_msg_log_status VARCHAR2 (4000);

       p_o_status                    VARCHAR2 (100);

       p_o_err_msg                   VARCHAR2 (100);

    P_i_input_res_xml XMLTYPE;

    BEGIN

    p_o_status := 'S' ;

    p_o_err_msg := NULL;

    Dbms_output.put_line ()' Start... process_response_xml ');

    FOR i

    IN (SELECT x. code , x . gravity , x . Description                   

    DE XMLTABLE ( )

    xmlnamespaces (DEFAULT ' urn: xyz:ccw:config:common: data'()

    , ' for $i in //error

    Returns the element r {}

    $i / code,.

    $i / description.

    $i / gravity

    }'

    By the WAY P_i_input_res_xml

    COLUMNS

                  code  VARCHAR2 (13) Path 'code'

    , gravity VARCHAR2 (30) Path "gravity"

    , Description VARCHAR2 (30) Path 'description'

    ) x )

    LOOP

    DBMS_OUTPUT.put_line ) ( )

    ' code : ' || i . code );

    DBMS_OUTPUT.put_line ) ( )

    ' severity: ' || i . gravity );

    DBMS_OUTPUT.put_line ) ( )

    ' description: ' || i . Description );

    main_error_check := i . code of : main_error_check;

    INSERT IN xxgco_config_validate ()event_status ERROR_CODE error_description ,error_severity creation_date event_key last_update_date( )

    VALUES('E',i. code , i . Description , i . gravity SYSDATE, p_i_event_key , SYSDATE);

    RETURN 'E' ;

    END LOOP;

    DBMS_OUTPUT.put_line ()' main_error_check:' : main_error_check);

    DBMS_OUTPUT.put_line ()' COMPLETED:');

    IF main_error_check IS NULL

    THEN

    FOR i

    IN (SELECT x. code , x . gravity , x . Description , x . subcause                   

    DE XMLTABLE ( )

    xmlnamespaces (DEFAULT ' urn: xyz:ccw:config:common: data'()

    , ' for $i in //message

    Returns the element r {}

    $i / code,.

    $i / description.

    $i / gravity,.

    $i / subCause

    }'

    By the WAY P_i_input_res_xml

    COLUMNS

                  code  VARCHAR2 (13) Path 'code'

    , gravity VARCHAR2 (30) Path "gravity"

    , Description VARCHAR2 (30) Path 'description'

    , subCause VARCHAR2 (50) Path "subCause"

    ) x )

    LOOP

    DBMS_OUTPUT.put_line ) ( )

    "code:" || i . code );

    DBMS_OUTPUT.put_line ) ( )

    ' severity: ' || i . gravity );

    DBMS_OUTPUT.put_line ) ( )

    ' description: ' || i . Description );

    DBMS_OUTPUT.put_line()' subCause:': i. subCause );

    INSERT IN xxgco_config_validate ()event_status ERROR_CODE error_description ,error_severity error_cause creation_date event_key last_update_date( )

                        VALUES('E',i. code , i . Description , i . gravity , i . subcause SYSDATE, p_i_event_key , SYSDATE);

    main_error_check1 := i . code of : main_error_check1;

    END LOOP;

    IF main_error_check1 IS NOT NULL

    THEN

    RETURN ('E');

    ON THE OTHER

    RETURN ('S');

    END IF;

    ON THE OTHER

    -TODO Log main error Log

    RETURN ('E');

    END IF;

    EXCEPTION

    WHEN Others

    THEN

    p_o_err_msg :=

    SUBSTR (

    ' Error in the response_XML_error_log FUNCTION:'

                || SUBSTR (SQLERRM, 1, 250)

                || ':'

                || DBMS_UTILITY.format_error_backtrace ,

    1 ,

    4000 );

    RETURN 'E' ;

    END XML_error_log ;



    Thanks in advance

    Ok.. This isn't a constructive debate...

  • I would like to create an interactive pdf in Indesign - two guest on 1 page in Indesign that when exporting to adobe reader in pdf format, I can simply add new names that populate both copies and then be printable. Any help out there is how to make an ext

    Two invites on 1 page in Indesign that when exporting to adobe reader in pdf format, I can simply add new names that populate both copies and then be printable. Any help out there is how to make an invitation in Indesign, but now how to make 2 copies on a single page that someone else ie the customer can add their own names. So each field name must complete on both guest. Sounds simple, but is not really there to help. I think he called an interactive pdf. Thanks in advance.

    AutoFill is the easiest part, he lies. If both fields have the same name, they will have the same content: type in one and it appears in the other.

Maybe you are looking for