Question on the "Binder" two queries

I get an error when I run the following code (see below).
Why then I 'tie' these 2 queries together like this?
Both will work fine by themselves and give me good data, I just need to connect.
For a sql start class, so I all I really want is to explain why this is not allowed.
I'm not find the answer in the book I have.
Any idea for a newb appreciated!
SQL> SELECT order#, isbn, title, SUM(quantity) AS SubTotal
2        FROM orderitems RIGHT OUTER JOIN books USING (isbn)
3        GROUP BY order#, isbn, title
4        ORDER BY order#
5 WHERE (isbn, title) IN
6                     (SELECT isbn, title
7                       FROM books
8                       WHERE retail - cost >
9                                        (SELECT AVG(SUM(retail - cost))
10                                         FROM books
11                                        GROUP BY isbn));
WHERE (isbn, title) IN
*
ERROR at line 5:
ORA-00933: SQL command not properly ended

Hello

When the following clauses are used, they should always be in the following order:

WHERE
GROUP BY
ORDER BY

You can override any (or all) of these, but when you use them, they must come in that order.

Move the WHERE clause (all, up to, but excluding, the semicolon) before the GROUP BY clause.

Tags: Database

Similar Questions

  • 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
    
  • Media Center Question can I have set up as a server and the other two as clients, each using two of the tuners of the card?

    I have 3 computers running Windows 7 Professional, one of them has a four installed tuner DVB - s2 card. I want to configure it as a server and the other two as clients, each using two of the tuners of the card. I understand the media library is able to use the basic network TV tuning cards, so there must be some way for me to configure the server to send the information over the network.

    Any ideas?

    On Fri, September 19, 2014 12:28:56 + 0000, SamJ008 wrote:
     
    > I have 3 computers running Windows 7 Professional, one of them has a four installed tuner DVB - s2 card. I want to configure it as a server and the other two as clients, each using two of the tuners of the card. I understand the media library is able to use the basic network TV tuning cards, so there must be some way for me to configure the server to send the information over the network.
    >>
    >>
    >>
    > Any ideas
     
     
    Start reading here
     
    You will not be able to use your existing tuners like tuner network. Microsoft has
    arrested development of Media Center, so don't expect any new hardware/software to
    appear.
     
     
     
    __________________________________________________________________________________________________
    Barb
    MVP Windows Entertainment and connected home
     
    Please mark as answer if that answers your question
     
     
     
  • 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...

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

  • 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

  • Two questions about the controller of the exporter

    Hi guys,.

    I have two questions on the controller of the exporter.

    1. as the controller of the exporter uses its own user interface, is it possible to generate new files pre-defined in the controller of the exporter to represent its user interface is happy?

    2. how the Ftp settings are stored in the preset currently file? I want to change in my own exporting contronller rather than first UI.

    It will be very appreciated if someone could answer these questions.

    Thank you.

    Hi Alex,

    (1) there is no API to create/modify the presets of the exporter, but as you can see, the .epr file is XML and quite easy to debone in most regions.

    (2) Oh, I forgot this FTP settings checkbox save.  Good fishing!   Yes, the binary data in the .epr are encoded in base64.  The last time I checked (there are several versions), Premiere Pro checksum function is a CRC 32 bit with a polynomial of 0xEDB88320L.  It is not guaranteed to remain the same from one version to the other.

  • Use the bind variable in example of a clause giving questions

    create or replace procedure pr_mbk (p_val in number)
    is
    CROR type is ref cursor;
    REF CROR;
    type numbertype is the table of index number of pls_integer;
    numtype numbertype.
    v_str varchar2 (2000): = 'select empno from emp sample(:val) ";
    Start
    Open ref for v_str using p_val;
    Close ref;
    end;
    /

    Successfully compiled.

    But when I run the same

    Exec pr_mbk (10);

    ERROR on line 1:
    ORA-00933: SQL not correctly completed command.
    ORA-06512: at "SCOTT. PR_MBK', line 9
    ORA-06512: at line 1

    My question is can use us Bind variables within a sample clause.

    Receive your answer.

    Thank you
    Madhu K.

    I guess that SAMPLE is considered as a special case, and is not considered as something that takes a 'value' in the same way as values in where clause or values in the query itself.
    Let's face it, the SAMPLE is not the standard SQL syntax and is probably something Oracle implements in a separate thread for processing SQL itself i.e. engine Oracle saying to herself... "I will remember this bit of the sample until I questioned the data using the SQL engine, so I'll take a suitable sample of the results," but it's the SQL engine treats the binding of values and the Oracle process that awaits the results taste, knows nothing of the binding values in it's special EXAMPLE of keyword.

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

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

  • Please help me with the Alternative of queries to replace the UNION ALL for two queries

    Hi all

    I have the query to retrieve assets employees salary count and in so far as below:

    Select ename, emp_no, sum (sal_till_2010), sum (sal_till_2014) of

    (select emp_no, ename, salary as sal_till_2010, 0 as sal_till_2014 of employee e1

    where effective_date < = 1 January 2010 ' and not exists (select 1 from e2 employee_deletion where e2.emp_no = e1.emp_no and e2.deletion_date < = January 1, 2010 "")

    UNION ALL

    Select ename, emp_no, 0 as sal_till_2010, salary as employee e1 sal_till_2014 - here is a dummy 0 salary until 2010 for the union of all the

    where effective_date < = 1 January 2014 "and not exists (select 1 from e2 employee_deletion where e2.emp_no = e1.emp_no and e2.deletion_date < = 1 January 2014") "

    Group of emp_no, ename;

    In this query, I get the total salary until 2010 and until 2014 in the employee table, dates are dynamically passed to the procedure, and this can change.

    But assume the date above and let me know the alternative of queries to improve performance because I use Union ALL and read the same table twice in the above query.

    Advice me with request to read the table once to fetch the same data as the above query.

    Thanks in advance.


    Hello

    Thanks for the display of the data of the sample; It's very useful!

    I think OP wants something like this:

    WITH cutoff_dates AS

    (

    SELECT TO_DATE (January 1, 2010 ', ' DD/MM/YYYY') AS cutoff_date, 2010 UNDER the label OF dual UNION ALL

    SELECT TO_DATE (1 January 2014 ', "DD/MM/YYYY"), double 2014

    )

    SELECT e.emp_no, e.ename

    , NVL (SUM (CASE WHEN c.label = 2010 THEN e.salary END), 0) AS sal_till_2010

    , NVL (SUM (CASE WHEN c.label = 2014 THEN e.salary END), 0) AS sal_till_2014

    E employee

    JOIN cutoff_dates c ON e.effective_date<=>

    WHERE DOES NOT EXIST)

    SELECT 1

    Of employee_deletion ed

    WHERE ed.emp_no = e.emp_no

    AND ed.deletion_date<=>

    )

    E.emp_no GROUP, e.ename

    ORDER BY e.emp_no

    ;

    Output of your sample data:

    EMP_NO ENAME SAL_TILL_2010 SAL_TILL_2014

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

    1 Mickey 450 0

    2 Donald 750 0

  • I've lost the last two digits of my valid key for xp pro sp2 and notebook, how do I get the key and support? where?

    I've lost the last two digits of my valid key for xp pro sp2 and notebook, how do I get the key and support? where?

    Hi Jonathan,.

    Please go to the Microsoft Community Forums.
    After the description of the question, I understand that you have lost the last 2 digits of the product key.
    Let me go ahead and help you with the issue.
     
    Please answer these questions, which will help us to help you best.
    1. How did you get the product key?
    2. the operating system come preinstalled on the computer?
     
    I suggest you for the link and check if that helps:
    How to identify, locate, and replace a product key
     
    See also:

    I hope this helps. If you have any other queries/issues related to Windows, write us and we will be happy to help you further.
  • Information on how to execute SQL on the CUCM himself queries please

    Hello all,.

    I need to run a SQL on the CUCM enumerate all directory numbers, their score and their external mask values.

    I came across this snippet below earlier so I have a bit of an idea of how do but iw would be great to see some other examples of sql queries.

    Any help is most appreciated.

    Also, is there a document somewhere to tell me how to run these queries?

    Thanks in advance

    Concerning

    Amanda

    *******************************************************************************************************************************************************************************

    Helps you try if this the CLI SQL query execution, it must list all DN with CFA allowed the VM or a DN:

    run sql select dnorpattern, cfadestination, cfavoicemailenabled CallForwardDynamic c, numplan n where c.fknumplan = n.pkid and (cfadestination! = "or cfavoicemailenabled 't =')

    Hi Amanda

    Basically, this is standard SQL, so that he would not bad at google 'informix instructions' select and do a bit of reading to get the basics. There are millions of permutations of requests so it comes to understand the syntax and then only by applying to the database in question. The only difference when running the commands in the CLI are:

    -Precede you the standard informix with "execute sql" SQL statement

    -You get no help from CUCM with syntax, so you might be well advised to use something which includes SQL a bit and he colorized you type, and then paste the commands resulting in the CUCM SSH window. I use an editor called JEdit, if you create a text file and save it as a file ending with .sql, it will highlight your syntax.

    -Other programs are available that make reasonable syntactic (EQ SquirrelSQL) that are designed to query the DB directly, but you can't really query directly against the DB for security reasons. You will still need to copy and paste commands.

    Now... to understand the DB you will need a reference describing all the tables, etc.. Here it is:

    http://www.Cisco.com/en/us/products/SW/voicesw/ps556/products_programming_reference_guides_list.html

    Choose your version of CUCM and download the document 'data definition '.

    Some notes on the order:

    run sql: is just the CLI command which tells the shell to perform the following as SQL.

    Select: the SQL command to recover data

    dnorpattern, cfadestination, cfavoicemailenabled: column names to retrieve

    callforwarddynamic c, numplan n: the names of the two tables and abbreviations that you want to refer to them as

    where c.fknumplan = n.pkid: This tells SQL to return values in the two tables where these fields match. In the data definition, you will see notes that c.fknumplan (i.e. the column fknumplan in table callforwarddynamic, as indicated by the prefix c.) refers to the PKID column in the area of the numplan. It is a type of join in the very standard DB CCM.

    and ("cfadestination! =" or cfavoicemailenabled = "t"): another clause, fundamentally in this application that we want to see only the rows where cfadestination is not empty or cfavoicefmailenabled has the value 't' for real).

    Most of the tables are related in two ways in this database:

    -a column "fk" prefix refers to the field of pkid (there is always only one field per table pkid) in the table following the prefix "fk". For example above fknumplan refers to the numplan, pkid field table. fkdevice refers to the machine table, pkid field.

    -a prefiex of 'traditional knowledge' column usually refers to a table enum which is preceded by 'type '. It is a table that maps the numerical value in the field of 'traditional knowledge' into a string. An example would be tkmodel - it is the type of physical phone (e.g. as 7962) and mapped as the column and a table called typemodel model 'enum' in the table.

    Concerning

    Aaron Harrison

    Senior Engineer at Logicalis UK

    Please note the useful messages...

Maybe you are looking for