Order SQL ORA-00933 not correctly completed, UNION ALL

I apologize if it's really simple, but it made me turn round...

I inherited the spaghetti code to fix and revise (550 line sql request sent from VBA). I'm putting it in pieces in the form of views. In the following code, I'm calling two subqueries, which I stored in the form of views (Credit_Report_Exposure_P_Sub_A and Credit_Report_Exposure_P_Sub_B). I have create a UNION of them, and it works fine - until I add a WHERE clause. So:

---------------------------------------------------------------------------------
SELECT
PROFILENAME,
months,
sum

Of
Credit_Report_Exposure_P_Sub_A

UNION ALL

(SELECT
ccp_profile_name PROFILENAME,
VWMONTH month,
SUM SUM (PSJ_TOTAL_AMOUNT)
Of
Credit_Report_Exposure_P_Sub_B
GROUP by
VWMONTH,
ccp_profile_name)
------------------------------------------------------------------------------------------

It works very well, to select the same 3 columns in each subquery (ignoring for a moment the wrong choice of alias 'months' and 'sum').

But when I add the following WHERE clause:
------------------------------------------------------------------------------------------
WHERE
month = ' 2008-09'
------------------------------------------------------------------------------------------
I get the error in the subject line - which is not properly completed.

But: if I comment on each half of the UNION, so the WHERE clause works very well.

Am I missing something obvious? I tried wrapping the whole of the UNION more in parentheses, and the first clause of the UNION as well, but that only creates more errors on supposed lack of right parens.

Thanks for any help.

Hello

Whenever you have a problem with a query, view query. It is unclear where exactly you added the WHERE clause.

You don't need parentheses around the second part of the UNION all.

Half of the effect of the WHERE clause of the will UNION ALL? If both, you must add two times, or do the UNION ALL in a subquery and add the WHERE clause to the query of super.

Tags: Database

Similar Questions

  • Classic report command SQL ORA-00933 not properly completed when you enable sorting

    Hello

    Oracle 11g r2, APEX 4.1.1.00.23.

    I have a few reports of type SQL Query (PL/SQL, returning the SQL query function body), so the source is as follows:
    begin
      return points_ui.get_points_query(:P0_FILTER_TYPE);
    end;
    Without no sort option, the report is made successfully.

    But I got the following error during a test to enable the sorting option for a column:
    ORA-00933: SQL command not properly ended
    I read about this error on the Oracle forums, and I saw it was a bug in an older version, but I thought it was fixed in 4.0.2...

    Any help would be appreciated.

    Thank you.

    Yann.

    The Order By clause and the column sort is kind of mutually exclusive.
    If your SQL in the report area has an Order By inside and you apply the sort order on the columns in the report attributes tab, then errors occur during execution.

    Concerning

  • ora-00933 not correctly completed sql command

    The following query is implementation error. Please help fix

    Actual output

    Mv_payment operating data:
    program_key,amount,received_date
    14               400        07/11/2010
    14               200          
    14               300        08/11/2010
    
    Expected output
    from mv_payment_holding
    program_key        sum(amount)          latest received date
    14                        900                    08/11/2010
     SELECT DISTINCT 
      PROGRAM_NAME_ID ||'. '|| program_name_descr Surcharge,program_name_id,
      get_total('110831559486','90869506814') "Total Amount Due",t.program_key,
      nvl(T.PI_AMOUNT,0) "Penalty Interest",
      sum(nvl(h.Amount,0)) "Payment Amount",
      get_total('110831559486','90869506814')+nvl(T.PI_AMOUNT,0)+sum(nvl(Amount,0))  "Period Balance",
      max(to_char(h.received_date,'MM/DD/YY')) "Last Payment Date"
      FROM mv_program_dict P, mv_PROG_SURCH T,mv_billing b,mv_payment_holding h
      WHERE p.program_key= t.program_key(+)
      AND t.billing_key=b.billing_key
      AND b.company_id=h.company_id
      AND b.report_period=h.report_period
      AND t.program_key=h.program_key
      AND t.BILLING_KEY='110831559486'
      And t.program_key='90869506814'
      group by program_name_id,program_name_descr Surcharge,t.program_key,PI_AMOUNT
      order by PROGRAM_NAME_ID
    Published by: KK on March 28, 2011 10:24

    If you want just your output of the mv then

    SELECT program_key, SUM (amount), MAX (received_date)
      FROM mv_payment_holding
    GROUP BY program_key;
    

    you are missing a comma in group by.

    SELECT DISTINCT
           PROGRAM_NAME_ID || '. ' || program_name_descr Surcharge,
           program_name_id,
           get_total ( '110831559486', '90869506814') "Total Amount Due",
           T.program_key,
           NVL (T.PI_AMOUNT, 0) "Penalty Interest",
           SUM (NVL (h.Amount, 0)) "Payment Amount",
             get_total ( '110831559486', '90869506814')
           + NVL (T.PI_AMOUNT, 0)
           + SUM (NVL (Amount, 0))
             "Period Balance",
           MAX (TO_CHAR ( h.received_date, 'MM/DD/YY')) "Last Payment Date"
      FROM mv_program_dict P,
           mv_PROG_SURCH T,
           mv_billing b,
           mv_payment_holding h
     WHERE P.program_key = T.program_key(+)
       AND T.billing_key = b.billing_key
       AND b.company_id = h.company_id
       AND b.report_period = h.report_period
       AND T.program_key = h.program_key
       AND T.BILLING_KEY = '110831559486'
       AND T.program_key = '90869506814'
    GROUP BY program_name_id,
             program_name_descr,
             T.program_key,
             PI_AMOUNT
    ORDER BY PROGRAM_NAME_ID
    

    Published by: Ganesh aboumagahrif March 28, 2011 13:33

  • ORA-00933: SQL not correctly completed command.

    Hello

    I get the following error:-ORA-00933: SQL not correctly completed command

    select
                (select max(x.exec_id) from log_exec x) exec_id,
                'c2uv_sys_map' table_name, 'All' upload_file_name,
                count(*) rows_ok, 0 rows_duplicate, 0 rows_rejected, 0 rows_bad, e.upload_file_id
                from c2uv_sys_map e
                where e.row_err_id=0
                group by e.upload_file_id
                UNION
                select max(x.exec_id) from log_exec x) exec_id,
                'c2uv_sys_map' table_name, 'All' upload_file_name,
                count(*) rows_ok, 0 rows_duplicate, 0 rows_rejected, 0 rows_bad, e.upload_file_id
                from c2uv_sys_map e
                group by e.upload_file_id
                UNION
                select (select max(x.exec_id) from log_exec x) exec_id,
                'c2uv_sys_map' table_name, 'All' upload_file_name,
                0 rows_ok, count(*) rows_duplicate, 0 rows_rejected, 0 rows_bad, e.upload_file_id
                from c2uv_sys_map  e
                where e.row_err_id=2
                group by e.upload_file_id
                UNION
                select (select max(x.exec_id) from log_exec x) exec_id,
                'c2uv_sys_map' table_name, 'All' upload_file_name,
                0 rows_ok, 0 rows_duplicate, count(*) rows_rejected, 0 rows_bad, e.upload_file_id
                from c2uv_sys_map  e
                where (e.row_err_id =1) or (e.row_err_id >2)
                group by e.upload_file_id
                UNION
                select (select max(x.exec_id) from log_exec x) exec_id,
                'c2uv_sys_map' table_name, 'All' upload_file_name,
                0 rows_ok, 0 rows_duplicate, 0 rows_rejected, u.no_of_bad_rows rows_bad, t.upload_file_id
                from c2uv_sys_map t right outer join chn_upload u on t.upload_file_id = u.config_id
                inner join chn_upload_config c on u.config_id = c.config_id
                inner join chc_data_filetype f on c.data_filetype_id = f.data_filetype_id
                where f.data_filetype_id = 11
                group by u.no_of_bad_rows, t.upload_file_id
    Edited by: 872435 January 6, 2012 06:09

    It seems that this parenthesis corresponds to nothing:

    select (select max(x.exec_id) from log_exec x) exec_id,
           'c2uv_sys_map' table_name,
           'All' upload_file_name,
           count(*) rows_ok,
           0 rows_duplicate,
           0 rows_rejected,
           0 rows_bad,
           e.upload_file_id
      from c2uv_sys_map e
     where e.row_err_id = 0
     group by e.upload_file_id
    UNION
    select max(x.exec_id)
      from log_exec x)         -- <-- Here
    ...
    
  • XML request error. ORA-00933: SQL not correctly completed command.

    Hi all

    My Version of the database: Oracle Database 10g Enterprise Edition Release 10.1.0.2.0.

    CREATE table test (name VARCHAR2 (3), identification number);

    Insert test values ('abc', 61);

    Insert test values ('def', 46);

    Select table_name,
    column_name,
    search_string 'abc ',.
    result
    CLO, xmltable (('ora: view("'||))) table_name |' ") / RANK /' | column_name | "[ora:contains (text,' %'|)] "abc". "% ») > 0]')
    result varchar2 columns (10) path '.'
    )
    where table_name in ('TEST');

    and I get: ORA-00933: SQL not correctly completed command it points on ' * xmltable *'
    SQL> SELECT extractValue(value(t), '/CustomerInformation/Customerid') "Customerid"
      2       , extractValue(value(t), '/CustomerInformation/CustomerName') "CustomerName"
      3       , extractValue(value(t), '/CustomerInformation/Country') "Country"
      4  FROM xml_document_table x
      5     , TABLE(
      6         XMLSequence(
      7           extract(x.xml_document, '/Customer/CustomerInformation')
      8         )
      9       ) t
     10  ;
    
    Customerid            CustomerName             Country
    --------------------- ------------------------ -------------
    1                     xxxx                     4
    2                     yyyy                     5
     
    
  • Error: ORA-00933: SQL not correctly completed command

    Hello

    When I run the query of delimit (who used to write the result of refsursor) in sql * plus, it works well.
    OPEN result FOR
         SELECT site_direction_id direction_numbers,
               site_lane_id lane_numbers
          FROM site_lanes
             JOIN report_parameters 
               ON site_lane_id = report_parameter_value
            WHERE site_lanes.site_id = my_site_id
              AND report_parameters.report_parameter_id  = in_report_parameter_id
              AND report_parameters.report_parameter_group = 'LANE'
           AND report_parameters.report_parameter_name  = 'LANE'
      ORDER BY site_direction_id ASC,
               site_lane_id ASC
          FROM SYS.DUAL;
    But inside a procedure, when compiling, throwing me the following error message. I'm not sure why it generates this error.
     ----------------------------------------------------
     PL/SQL: SQL Statement ignored
     PL/SQL: ORA-00933: SQL command not properly ended
    Could someone help me?

    Thank you.

    Published by: user10641405 on June 8, 2009 11:39

    Hello

    It really works in SQL * more? He has two FROM clauses.

    You probably want to remove 'OF SYS. DOUBLE"of the last line.

  • PL/SQL: ORA-00933: SQL not correctly completed command

    Hello

    CREATE or REPLACE PROCEDURE SAI (STATUS_CODE OUT varchar2)
    AS
    BEGIN
    Select ename emp in STATUS_CODE where empno = '7369';
    END SAI;

    I get the error "* not correctly completed SQL command * ' when executing this procedure. Help, please.

    Hello

    user10503747 wrote:
    Hello

    CREATE or REPLACE PROCEDURE SAI (STATUS_CODE OUT varchar2)
    AS
    BEGIN
    Select ename emp in STATUS_CODE where empno = '7369';
    END SAI;

    I get the error "* not correctly completed SQL command * ' when executing this procedure. Help, please.

    I want to tell u that you made mistake of bases...

    First you write a wrong syntax for your sql statement

    Select ename emp in STATUS_CODE where empno = '7369';

    its should be like

    Select ename from STATUS_CODE from emp where empno = '7369';

    your entire procedure will be as

    CREATE OR REPLACE PROCEDURE SAI (STATUS_CODE out varchar2)
    AS
    BEGIN
    select last_name into STATUS_CODE from employees where employee_id=102;
    END SAI ;
    

    and after that, you must declare a variable of liaison

    Return_name VARIABLE VARCHAR2 (30);

    Then exceute your interior

    exec sai(:return_name);

    print your value of variable binding

    print :return_name;
    
    RETURN_NAME
    --------------------------------
    De Haan
    

    Regards

    UMI

  • drop the triggers in the SQL code causes not properly completed order.

    running the following command in SQL developer, giving the following error message
    ORA-00933: SQL not correctly completed command.
    What I am doing wrong
    Begin  
    For I In (Select Trigger_Name, Owner From Dba_Triggers Where Trigger_Name Like 'ABC%' And Owner = 'my_schema')
      Loop  
        Execute Immediate 'DROP TRIGGER '||I.Owner||'.'||I.Trigger_Name;  
      End Loop;  
    End;
    Published by: Mo2 on April 16, 2010 12:21

    Published by: Mo2 on April 16, 2010 12:24

    MO2 wrote:
    Yes he has.
    is an example of the names BIN$ + i6ls2WnR/Svz0wA5LSG8A == $0

    In fact these triggers created by the database after I have remove the tables. is there a way to avoid their creation?

    drop trigger BIN$+i6ls2WnR/Svz0wA5LSG8A==$0;
    drop trigger BIN$+i6ls2WnR/Svz0wA5LSG8A==$0
                     *
    ERROR at line 1:
    ORA-00933: SQL command not properly ended
    

    Yes, oracle complained about it during a fall.
    These objects will be created if you recyclebin on.

    You can either disable your recyclebin or you can purge these items in recyclebin after a fall. Make sure that you require this function or objects in the future.

    Concerning
    Anurag

  • Can someone help me - error:-not correctly completed SQL command

    Hello

    This code has an error, I tried to find this error but I don't find it so please help me: -.

    error report:
    ORA-06550: line 1, column 149:
    PL/SQL: ORA-00933: SQL not correctly completed command
    ORA-06550: line 1, column 7:
    PL/SQL: SQL statement ignored

    Code

    Select HTMLDB_ITEM. HIDDEN(1,SEQ_ID),
    HTMLDB_ITEM. C001 Text(2,a.C001).
    HTMLDB_ITEM. C002 Text(3,a.C002).
    HTMLDB_ITEM. C003 Text(4,a.C003).
    APEX_ITEM. SELECT_LIST_FROM_QUERY (5, a.c004, 'SELECT D P_ID, P_ID R OF PARTY_DETAIL') c004.
    APEX_ITEM. SELECT_LIST_FROM_QUERY
    (6, a.c005,)
    ' SELECT CATEGARY_NAME D, ' |' CATEGARY_NAME ITEM_CATEGARY R'.
    "style =" width: 220px "'"
    ||' OnChange = "get_select_list_xml1 (this, e
    || 'f7_ '.
    || LPAD (seq_id, 4, '0')
    || ')"',
    '' YES. ''
    '0',
    "- Select -",
    « f6_ » || LPAD (seq_id, 4, '0'),
    NULL,
    'NO') c005
    APEX_ITEM. SELECT_LIST_FROM_QUERY
    (7, a.c006,)
    "SELECT ITEM_CODE D.
    ||' ITEM_CODE ITEM_MASTER R'
    ||' WHERE CATEGARY_NAME ='
    || C005,
    "style =" width: 220px "',"
    '' YES. ''
    '0',
    "- Select Code (')"
    || (Select Count (*)
    of ITEM_MASTER
    where CATEGARY_NAME = c005)
    || ')-',
    « f7_ » || LPAD (seq_id, 4, '0'),
    NULL,
    'NO') c006
    APEX_ITEM. SELECT_LIST_FROM_QUERY (8, a.c007, 'SELECT nom_element, nom_element R OF ITEM_MASTER D') c007,.
    HTMLDB_ITEM. C008 Text(9,a.C008).
    APEX_ITEM. SELECT_LIST_FROM_QUERY (10, a.c009, 'SELECT PACK_TYPE D, PACK_TYPE R OF ITEM_PACKING') c009,.
    HTMLDB_ITEM. Text(11,a.C010) c010.
    HTMLDB_ITEM. Text(12,a.C011) c011.
    HTMLDB_ITEM. C012 Text(13,a.C012).
    HTMLDB_ITEM. C013 Text(14,a.C013)
    OF wwv_flow_collections one
    where a.collection_name = 'REC_ITEM. '




    Thank you
    Maury

    Published by: Ed on September 10, 2009 03:36

    Can you copy and paste this code into SQL * more and see if it runs properly? You can check your single quote (') and double quote characters ("") to make sure that those who at the height correctly because it is difficult to say when copied on the web.

  • Not correctly completed SQL command

    can not find why this error occurs: not correctly completed SQL command

    PROCEDURE FORMA4_25_11)

    P_GO IN VARCHAR2,

    P_DATE_1 IN VARCHAR2,

    P_DATE_2 IN VARCHAR2,

    P_DAY_COUNT NUMBER,

    DATA_SET ON SYS_REFCURSOR)

    AS

    DB_QUERY VARCHAR (32767).

    BEGIN

    DB_QUERY: = ' SELECT T1.ad, T1.admin_count, T1.cnt)

    SELECT dc.NAME ad,

    Count (am. IDN) admin_count,.

    Admn.Say NTC

    SINCE DC dictionaries.customs

    INNER JOIN kadr.tper_master mf

    ON mf.branch_code = dc.code_int AND mf.status = 0

    INNER JOIN vpdgk.vp_admin am

    ON am.mufet_id = mf.idn

    LEFT JOIN (SELECT branch_code,

    Say Count (branch_code) AS

    OF (m_id SELECT c.mufet_id,

    b.branch_code,

    Count (c.mufet_id) mufet_count

    OF vpdgk.vp_qeydiyyat A

    INNER JOIN kadr.tper_master b

    ON b.idn = a.mufet_id

    INNER JOIN vpdgk.vp_admin c

    ON c.mufet_id = A.mufet_id

    AND (c.uid_ IS NOT NULL

    GOLD c.uid_reserv IS NOT NULL)

    INNER JOIN dictionaries.customs d

    ON d.code_int = b.branch_code

    WHEN Trunc (A.insert_date) BETWEEN

    TO_DATE('''||) P_DATE_1 | " ', "DD. MM YYYY ")

    AND

    TO_DATE('''||) P_DATE_2 | " ', "DD. MM YYYY ")

    C.mufet_id GROUP, b.branch_code

    HAVING COUNT (c.mufet_id) < ' | P_DAY_COUNT |')

    GROUP BY branch_code Admn)

    ON admn.branch_code = dc.code_int

    Dc.NAME, admn.say) AS T1 WHERE T1.ad = ' | P_GO | ";

    DATA_SET OPEN FOR DB_QUERY;

    END;

    Hi Afa

    At the end of SQL you write 'AS '. Remove it

    Excample:

  • PL/SQL: ORA-00947: not enough values error message

    Hi all I get Error (25.63): PL/SQL: ORA-00947: not enough error message values when executing after the insert statement. I am new to Oracle SPs, if someone could help me solve the problem.

    Insert in estimate (ID, mValue) values ('select (where pm.ID is null then 10))
    of other pm.ID
    End ID), m1.mID, (case when mValue < 1 and m1.mID in (1.7))
    then mValue * 100
    of another mValue
    mValue end) of
    Scott. Left outer join METRICS m1
    Scott. (PROJECTMETRIC h m1.mID = pm.ID and pm.ID = 10)');

    The syntax to insert rows into a table of a subquery is as follows:

    insert into table (col1, col2, ...)
    select ... , ..., ....
    from ..., ....
    where ....
    /
    
  • ORA-00933: SQL not correctly completed command (similar question titles exist - can not find my question).

    Hi all

    I have a couple of (relatively simple) tables (see DDL and DML below and try to join them,)

    but I get the error ORA-00933 - and I can't for the life of understand me why?

    I also put this on SQLFiddle for those who do not have a very convenient server.

    This is the SELECT query - internal works without problem, but I can't

    all for work.

    Any help appreciated - TIA and rgs,

    Paul...

    [code]

    CREATE TABLE ticket

    (

    ticket_id INT PRIMARY KEY,

    ticket_description VARCHAR (25)

    );

    INSERT INTO ticket VALUES (1, 'ticket 1');

    INSERT INTO ticket VALUES (2, 'ticket 2');

    INSERT INTO ticket VALUES (3, ' ticket 3 ");

    INSERT INTO ticket VALUES (4, 'ticket 4');

    INSERT INTO ticket VALUES (5, 'ticket 5');

    CREATE TABLE my_comment

    (

    comment_id INT PRIMARY KEY,

    ticket_id INT NOT NULL,

    comments_comment VARCHAR (45) NOT NULL,

    comments_timestamp INT NOT NULL

    );

    INSERT INTO my_comment VALUES (1, 1, 'comment 1 ticket to 1', ((TO_DATE ('2013-11-30 15:15:30 ', ' yyyy-mm-jj HH24:mi:ss)-TO_DATE ('1970-01-01 00:00:00 ',' yyyy-mm-dd HH24:mi:ss)) * 86400));))

    INSERT INTO my_comment VALUES (2, 1, 'Comment 2 1 notes', ((TO_DATE ('2014-02-13 15:15:30 ', ' yyyy-mm-jj HH24:mi:ss)-TO_DATE ('1970-01-01 00:00:00 ',' yyyy-mm-dd HH24:mi:ss)) * 86400));))

    INSERT INTO my_comment VALUES (3, 1, ' comment 3 tickets on 1', ((TO_DATE ('2014-06-30 15:15:30 ', ' yyyy-mm-jj HH24:mi:ss)-TO_DATE ('1970-01-01 00:00:00 ',' yyyy-mm-dd HH24:mi:ss)) * 86400));))

    INSERT INTO my_comment VALUES (4, 1, ' comment 4 tickets on 1', ((TO_DATE ('2014-07-09 15:15:30 ', ' yyyy-mm-jj HH24:mi:ss)-TO_DATE ('1970-01-01 00:00:00 ',' yyyy-mm-dd HH24:mi:ss)) * 86400));))

    INSERT INTO my_comment VALUES (5, 2, 'comment 1 ticket in 2', ((TO_DATE ('2013-11-30 15:15:30 ', ' yyyy-mm-jj HH24:mi:ss)-TO_DATE ('1970-01-01 00:00:00 ',' yyyy-mm-dd HH24:mi:ss)) * 86400));))

    INSERT INTO my_comment VALUES (6, 2, 'Comment 2 on 2 ticket', ((TO_DATE ('2014-02-13 15:15:30 ', ' yyyy-mm-jj HH24:mi:ss)-TO_DATE ('1970-01-01 00:00:00 ',' yyyy-mm-dd HH24:mi:ss)) * 86400));))

    INSERT INTO my_comment VALUES (7, 2, 'comment on ticket 2 3', ((TO_DATE ('2014-07-30 15:15:30 ', ' yyyy-mm-jj HH24:mi:ss)-TO_DATE ('1970-01-01 00:00:00 ',' yyyy-mm-dd HH24:mi:ss)) * 86400));))

    INSERT INTO my_comment VALUES (8, 2, 'comment on ticket 2 4', ((TO_DATE ('2014-08-09 15:15:30 ', ' yyyy-mm-jj HH24:mi:ss)-TO_DATE ('1970-01-01 00:00:00 ',' yyyy-mm-dd HH24:mi:ss)) * 86400));))

    INSERT INTO my_comment VALUES (9, 3, 'comment 1 ticket of 3', ((TO_DATE ('2001-11-30 15:15:30 ', ' yyyy-mm-jj HH24:mi:ss)-TO_DATE ('1970-01-01 00:00:00 ',' yyyy-mm-dd HH24:mi:ss)) * 86400));))

    INSERT INTO my_comment VALUES (10, 3, 'Comment 2 tickets in 3', ((TO_DATE ('2002-02-13 15:15:30 ', ' yyyy-mm-jj HH24:mi:ss)-TO_DATE ('1970-01-01 00:00:00 ',' yyyy-mm-dd HH24:mi:ss)) * 86400));))

    INSERT INTO my_comment VALUES (11, 3, 'comment on ticket 3 3', ((TO_DATE ('2004-06-30 15:15:30 ', ' yyyy-mm-jj HH24:mi:ss)-TO_DATE ('1970-01-01 00:00:00 ',' yyyy-mm-dd HH24:mi:ss)) * 86400));))

    INSERT INTO my_comment VALUES (12, 3, ' comment 4 tickets in 3', ((TO_DATE ('2004-07-09 15:15:30 ', ' yyyy-mm-jj HH24:mi:ss)-TO_DATE ('1970-01-01 00:00:00 ',' yyyy-mm-dd HH24:mi:ss)) * 86400));))

    INSERT INTO my_comment VALUES (13, 4, 'comment 1 ticket on 4', ((TO_DATE ('2003-11-30 15:15:30 ', ' yyyy-mm-jj HH24:mi:ss)-TO_DATE ('1970-01-01 00:00:00 ',' yyyy-mm-dd HH24:mi:ss)) * 86400));))

    INSERT INTO my_comment VALUES (14, 4, 'Comment 2 tickets in 4', ((TO_DATE ('2004-02-13 15:15:30 ', ' yyyy-mm-jj HH24:mi:ss)-TO_DATE ('1970-01-01 00:00:00 ',' yyyy-mm-dd HH24:mi:ss)) * 86400));))

    INSERT INTO my_comment VALUES (15, 4, 'comment on ticket 4 3', ((TO_DATE ('2004-07-09 15:15:30 ', ' yyyy-mm-jj HH24:mi:ss)-TO_DATE ('1970-01-01 00:00:00 ',' yyyy-mm-dd HH24:mi:ss)) * 86400));))

    INSERT INTO my_comment VALUES (16, 4, ' comment 4 tickets 4', ((TO_DATE ('2006-06-30 15:15:30 ', ' yyyy-mm-jj HH24:mi:ss)-TO_DATE ('1970-01-01 00:00:00 ',' yyyy-mm-dd HH24:mi:ss)) * 86400));))

    INSERT INTO my_comment VALUES (17, 5, 'comment 1 ticket to 1', ((TO_DATE ('2013-11-30 15:15:30 ', ' yyyy-mm-jj HH24:mi:ss)-TO_DATE ('1970-01-01 00:00:00 ',' yyyy-mm-dd HH24:mi:ss)) * 86400));))

    INSERT INTO my_comment VALUES (18, 5, 'Comment 2 on 2 ticket', ((TO_DATE ('2014-02-13 15:15:30 ', ' yyyy-mm-jj HH24:mi:ss)-TO_DATE ('1970-01-01 00:00:00 ',' yyyy-mm-dd HH24:mi:ss)) * 86400));))

    INSERT INTO my_comment VALUES (19, 5, 'comment on ticket 3 3', ((TO_DATE ('2014-06-30 15:15:30 ', ' yyyy-mm-jj HH24:mi:ss)-TO_DATE ('1970-01-01 00:00:00 ',' yyyy-mm-dd HH24:mi:ss)) * 86400));))

    INSERT INTO my_comment VALUES (20, 5, ' comment 4 tickets 4', ((TO_DATE ('2014-07-09 15:15:30 ', ' yyyy-mm-jj HH24:mi:ss)-TO_DATE ('1970-01-01 00:00:00 ',' yyyy-mm-dd HH24:mi:ss)) * 86400));))

    [\code]

    do not use 'UNDER' keyword in alias for the table

    SELECT t.ticket_id,

    t.ticket_description,

    x.c_max_date,

    z.comments_comment

    FROM (SELECT ticket_id, MAX (c.comments_timestamp) AS c_max_date

    OF my_comment c

    WHERE (c.comments_timestamp

    ((TO_DATE ('2013-11-30 15:15:30 ', ' yyyy-mm-jj HH24:mi:ss)-TO_DATE ('1970-01-01 00:00:00 ',' yyyy-mm-dd HH24:mi:ss)) * 86400-60000000)))

    )

    GROUP BY ticket_id) x

    INNER JOIN t ticket

    ON t.ticket_id = x.ticket_id

    INNER JOIN my_comment z

    WE z.comments_timestamp = x.c_max_date;

    ----

    Ramin Hashimzade

  • SQL - ORA-00979: not a GROUP BY expression

    Hi Expert,

    I received the error message: ORA-00979: not a GROUP BY expression at the bottom of the sql statement

    Please advise - display total number of point of sale and the total amount of all items. Only display results when the total quantity is greater than 2.

    SELECT o.Qty, sum(o.Qty*o.salesprice) AS TOTALDOLLARS, description and i.Itemcode
    OF ORDERLINE o
    INNER JOIN POINT I
    ON o.itemcode = i.itemcode
    GROUP BY i.Itemcode
    After having o.qty > 2

    > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > >

    Create table ORDERLINE
    (
    Qty number 4,
    Salesprice Number (6.2),
    OrderNo Number (3).
    ItemCode Varchar2 (6).
    Primary key (OrderNo, Itemcode)
    Foreign Key (Itemcode) refers to POINT.
    Foreign Key (OrderNo) made reference SALESORDER


    Create table POINT
    (
    ItemCode Varchar2 (6).
    Description Varchar2 (50).
    Retailprice Number (6.2),
    Number of weight (4.1),
    Purchaseprice Number (6.2),
    Category Varchar2 (20).
    Primary Key (Itemcode)
    );

    Hi 845720,

    Based on the sql code, the sum must be grouped itemcodewise, descriptionwise, qtywise.
    This means that you have all these in a group by clause too with sum().

    eg : group by  i.Itemcode, i.Description, o.Qty
    

    Is this wise sum qty is logical? I do not know...

    It will be useful,
    CKLP

    Published by: CKLP April 14, 2011 22:10

  • Current NetIncome do not correctly complete fairness after elimination

    The dilemma I have is that PL value circulating cannot not properly after actions in that elimination took place on the PL

    Both company A & B share a common parent called Parent1


    CYNetIncome is a liability account.

    NetIncome is a revenue account

    PKI dividend income= sales. PlugAccount = DividendsDiff

    DividendsPaid = passive (equity). Account = DividendsDiff card

    Societele reported NetIncome of $150. $50 is derived from a PKI dividend income (CompanyB receipt (as such relationships with partner PKI Societele value))

    CompanyB reports $50 of dividendspaid in equity with partner ICP Societele.  CompanyB reported NetIncome of $200

    A PL (income statement) Parent1should have NetIncome of $300 150-50(From CompanyA) + 200 (CompanyB). The deduction of $50 is the elimination of PKI dividend income. Value of TNE $300 to Parent1 is correct, but does not correct into account CYNetIncomes count NetIncome.

    The problem I have is Parent1 when the NetIncome fills CyNetIncome (CynetIncome = NetIncome) I get $350. He does not consider the elimination.

    No idea why this would happen is greatly appreciatee

    I have replaced #Functional with TotCustom1 C1 # C1 and this solved my problem

    Thank you

  • Aargh. "sql not correctly completed comand" - something wrong with my join...

    Select *.
    FROM table1 t1
    Join table2 t2 on t1.pkid = t2.pkid

    These aren't my real table names, but this structure is sufficient to generate my mistake. Clearly I can't join syntax. After Google search, I tried various permutations, with the join condition in parens, prefacing the names table with the schema and stuff like that. No change - always get ora00933.

    The only thing that worked was comma-ing, the tables and put the join condition in a where clause clause. Who doesn't for me in the end because the full query I need joined much more and it'll look terrible like that.

    Little help on just a simple inner join?

    Thank you!

    Edited by: sherifffruitfly January 4, 2011 10:18

    The ANSI join syntax was introduced in Oracle in version 9.1. Your version has been out of favor for a dozen years, and is the latest version of Oracle 11.2.

    Unless you can move to something of this century, to do joins in the where clause.

    John

Maybe you are looking for

  • Beats Audio disable

    Beats Audio won't turn on or off.  That's all the time.  Button beats on the right side of the laptop has no effect.  "Fn + b" function key has no effect.  This is on a HP Envy 14.

  • Deployment image for E30 problems

    Hello I tried to clone E30-win7-partition for eight other E30 identical. (7824-42-G) in this task done with the command "dd" distributed linux LiveCD. Subsequently these eight E30 computer cannot start Windows 7. In the past he has always worked with

  • S920 proximity sensor

    Hi, my S920 has a problem in the proximity sensor (the screen does not turn off during a phone call), I think it's a problem of software/calibration but the problem is when I go into the menu factory is all in Chinese and unfortunately I can't read C

  • Pavilion H8-1111: h8-1111 GPU Upgrade-&gt; Radeon HD6670 to NVIDIA GeForce 560Ti (possibly OEM)

    Hello HP I was offered a GPU that is better than what my office is came with originally. I currently have problems understanding if it works with current motherboard, I just like the old GPU Radeon... Technical reading is confusing, so I wanted to ju

  • Can't open any of my CR2 files from my Canon EOS 5 d Mark III using PS Cs6

    Hi, im in CS6I can't open any of my CR2 files from my Canon EOS 5 d Mark IIIPlease guide me on how to make this workThank youRalph