Help with Query Rewrite

Hi guru,.

First of all thank you very much for any help.

I want to rewrite the query to make fast performance to retrieve the records. I'm passing date as parameter and its data donations for 1 week.

I have an index on the column of rundate which I use in where clause. I select only forms a table in the entire query.

Can you please help me to rewrite the request or suggestions.

Thanks in advance!...
SELECT  TO_CHAR(SYSDATE, 'MM/DD/YYYY') AS "GENERATED ON",
       to_char(TRUNC(:pdate, 'Day'), 'mm/dd/yyyy')  AS "FROM DATE",
       to_char(TRUNC(:pdate, 'Day') + 6, 'MM/DD/YYYY')  AS "TO DATE",
       TOTAL_CALLS AS "TOTAL CALLS",
       DEPARTMENT AS "DEPARTMENT",
       TOTAL_DEPTCALLS AS "TOTAL DEPARTMENT CALLS",
       START_DATE AS "START DATE",
       ORIGINAL_CATEGORY AS "ORIGINAL CATEGORY",
       ORIGINAL_SUBCATEGORY AS "ORIGINAL SUBCATEGORY",
       GROUP_ID AS "GROUP ID",
       GROUP_NAME AS "GROUP NAME",
       TOTAL_BY_CAT_SUBCAT AS "TOTAL BY CAT-SUBCAT",
       ROUND((TOTAL_BY_CAT_SUBCAT / TOTAL_CALLS) * 100, 2) AS "% TOTAL BY CAT-SUBCAT",
       TOTAL_BY_GROUP AS "TOTAL BY GROUP",
       ROUND((TOTAL_BY_GROUP / TOTAL_CALLS) * 100, 2) AS "% TOTAL BY GROUP",
       TOTAL_BY_GROUP_CAT_SUBCAT AS "TOTAL BY GROUP CAT-SUBCAT"
  FROM (SELECT DEPARTMENT AS "DEPARTMENT",
               (SELECT count(1)  FROM PHONE_INQUIRY_CAUSE_REPORT RPT1
                         WHERE RPT1.RUNDATE >=  (TRUNC(:pdate, 'Day'))
                          and rpt1.rundate <= (TRUNC(:pdate, 'Day') + 6))
                           AS "TOTAL_CALLS",
               CASE
                 WHEN DEPARTMENT = 'M' THEN
                 (SELECT count(1) 
                             FROM PHONE_INQUIRY_CAUSE_REPORT RPT1
                            WHERE RPT1.RUNDATE >=  (TRUNC(:pdate, 'Day'))
                             and rpt1.rundate <= (TRUNC(:pdate, 'Day') + 6)
                              AND RPT1.DEPARTMENT = 'M')
                 WHEN DEPARTMENT = 'F' THEN
                  (SELECT count(1)
                             FROM PHONE_INQUIRY_CAUSE_REPORT RPT1
                            WHERE RPT1.RUNDATE >=  (TRUNC(:pdate, 'Day'))
                                     and rpt1.rundate <= (TRUNC(:pdate, 'Day') + 6)
                              AND RPT1.DEPARTMENT = 'F')
               END AS "TOTAL_DEPTCALLS",
               START_DATE AS "START_DATE",
               ORIGINAL_CATEGORY AS "ORIGINAL_CATEGORY",
               ORIGINAL_SUBCATEGORY AS "ORIGINAL_SUBCATEGORY",
               GROUP_ID AS "GROUP_ID",
               GROUP_NAME AS "GROUP_NAME",
              (SELECT count(1)
                FROM PHONE_INQUIRY_CAUSE_REPORT RPT2
               WHERE RPT2.RUNDATE >= (TRUNC(:pdate, 'Day')) AND
                     RPT2.RUNDATE <= (TRUNC(:pdate, 'Day') + 6)
                 AND RPT2.ORIGINAL_CATEGORY = rpt.original_category
                 AND NVL(RPT2.ORIGINAL_SUBCATEGORY, '%') =
                     NVL(RPT.ORIGINAL_SUBCATEGORY, '%')
                ) AS "TOTAL_BY_CAT_SUBCAT",
           (SELECT count(1)
                FROM PHONE_INQUIRY_CAUSE_REPORT RPT2
               WHERE RPT2.RUNDATE >= (TRUNC(:pdate, 'Day')) AND
                     RPT2.RUNDATE <= (TRUNC(:pdate, 'Day') + 6)
                and rpt2.group_id = rpt.group_id
             ) AS "TOTAL_BY_GROUP",
             
             (
         SELECT count(1)
                FROM PHONE_INQUIRY_CAUSE_REPORT RPT2
               WHERE RPT2.RUNDATE >= (TRUNC(:pdate, 'Day')) AND
                     RPT2.RUNDATE <= (TRUNC(:pdate, 'Day') + 6)
                 AND RPT2.ORIGINAL_CATEGORY = rpt.original_category
                 AND NVL(RPT2.ORIGINAL_SUBCATEGORY, '%') =
                     NVL(rpt.original_subcategory, '%')
                 AND RPT2.GROUP_ID = rpt.group_id
            )  AS "TOTAL_BY_GROUP_CAT_SUBCAT"
         FROM PHONE_INQUIRY_CAUSE_REPORT RPT
         WHERE RPT.RUNDATE >=  (TRUNC(:pdate, 'Day'))
         AND rpt.rundate <= (TRUNC(:pdate, 'Day') + 6)
         ORDER BY ORIGINAL_CATEGORY, GROUP_ID)

Hello

Try to use the function SUMMARY, rather than the aggregate COUNT:

WITH    universe     AS
(
     SELECT  department
     ,       COUNT (*) OVER ()          AS total_calls
     ,       CASE
                     WHEN  department IN ('F', 'M')
                  THEN  COUNT (*) OVER (PARTITION BY  department)
          END                            AS total_deptcalls
          ,       start_date
          ,       original_category
          ,       original_subcategory
          ,       group_id
          ,       group_name
          ,       COUNT (*) OVER (PARTITION BY  original_subcategory)
                                                 AS total_by_subcat
          ,       COUNT (*) OVER (PARTITION BY  group_id)
                                              AS total_by_group
          ,       COUNT (*) OVER (PARTITION BY  original_subcategory
                                           ,           group_id
                                  )        AS total_by_subcat_group
     FROM    phone_inquiry_cause_report
     WHERE      rundate  >= TRUNC (:pdate, 'Day')
     AND      rundate  <  TRUNC (:pdate, 'Day') + 7
)
SELECT    TO_CHAR (SYSDATE,    'MM/DD/YYYY')     AS "GENERATED ON"
,         TO_CHAR (:pdate,     'MM/DD/YYYY')       AS "FROM DATE"
,         TO_CHAR (:pdate + 6, 'MM/DD/YYYY')       AS "TO DATE"
,         total_calls                           AS "TOTAL CALLS"
,         department
,         total_deptcalls               AS "TOTAL DEPARTMENT CALLS"
,         start_date                     AS "START DATE"
,         original_category                AS "ORIGINAL CATEGORY"
,         original_subcategory                AS "ORIGINAL SUBCATEGORY"
,         group_id                     AS "GROUP ID"
,         group_name                     AS "GROUP NAME"
,         total_by_cat_subcat                AS "TOTAL BY CAT-SUBCAT"
,         ROUND ( 100 * total_by_cat_subcat
                  / total_calls
          , 2
          )                    AS "% TOTAL BY CAT-SUBCAT"
,         total_by_group                AS "TOTAL BY GROUP"
,         ROUND ( 100 * total_by_group
                  / total_calls
          , 2
          )                    AS "% TOTAL BY GROUP"
,         total_by_group_cat_subcat           AS "TOTAL BY GROUP CAT-SUBCAT"
ORDER BY  original_category
,            group_id
;

I hope that answers your question.
If not, post a small example of data (CREATE TABLE and INSERT statements) and the results desired from these data.
Explain, using specific examples, how you get these results from these data.
Always say what version of Oracle you are using (for example, 11.2.0.2.0).
See the FAQ forum {message identifier: = 9360002}

Tags: Database

Similar Questions

  • Need help with Query Rewrite

    I have the SQL which contains a scalar subquery. I need to move the FROM clause scalar subquery. Please note that there is an OUTER JOIN in SQL.
    select CHDR.CHDRNUM POLICY_ID,
           CHDR.COWNNUM POL_OWNER,
           (Select Lifcnum
                     From Odslifeasia.Lifepf
                    Where Life = '01'
                      And Jlife = '00'
                      And Validflag <> '2'
                      AND CHDRNUM = CHDR.CHDRNUM
                      and rownum = 1) LIFE_ASSURED,
           CHDR.BILLCHNL,
          ( Select Facthous
             From Odslifeasia.Clbapf Clba, Odslifeasia.Mandpf Mand
            Where Clba.Validflag = '1'
              And Clba.Clntnum = mand.Payrnum
              And Clba.Clntcoy = Mand.Payrcoy
              And Clba.Bankacckey = Mand.Bankacckey
              And (Mand.Payrnum = Chdr.Payrnum Or
                  Mand.Payrnum = Chdr.Cownnum)
              And (Mand.Payrcoy = Chdr.Payrcoy Or
                  Mand.Payrcoy = Chdr.Cowncoy)
              And Mand.Mandref = Chdr.Mandref
              And Chdr.Billchnl In ('D', 'K', 'S')
              And Mand.Validflag = '1'
              And Mand.Mandstat = '10'
              and rownum = 1) Facthous,
               ACM_DATE,
              (Select Dc.Longdesc
              From Odslifeasia.Descpf Dc
             Where Dc.Descitem = CHDR.BILLCHNL
               And Dc.Desctabl = 'T3620'
               And DC."LANGUAGE" = 'E'
               And Dc.Desccoy = '2'
               And Dc.Descpfx = 'IT'
               And Rownum = 1) BILL_CHNL_NAME
           from odslifeasia.chdrpf chdr
           left outer join
             (SELECT chdrnum, MAX(DATESUB) acm_date FROM ODSLIFEASIA.PTRNPF
              WHERE PTRNPF.Batctrcde = 'B673' group by chdrnum) PTRN on (ptrn.CHDRNUM = chdr.CHDRNUM)
           where CHDR.VALIDFLAG IN ('1', '3');

  • Help with query Oracle?

    Help with query Oracle?

    Take a look at the query

    Select channel_desc, sum (unit_cost), AVG (Unit_price) of channels C, cost S

    where C.channel_id = S.channel_id

    Group 1,2,3



    the first time the error is "channel_desc not a group by expression"-desc is a varchar type there are 6 channels

    II remove the group by clause and then pops up an error "" not only - group expression to group "".

    All the ideas!

    Select channel_desc, sum (unit_cost), AVG (Unit_price) of channels C, cost S
    where C.channel_id = S.channel_id
    Channel_desc group

  • Need help with query SQL Inline views + Group

    Hello gurus,

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

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

    Please ignore '-' added for clarity

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

    The query should return the following data set

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

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


    Thank you
    Nick

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

    Need help with query SQL Inline views + Group

    Kind regards.

    LOULOU.

  • Need help with query Cumulative difference

    Hi all

    I need help with a query and my requirement is as below

    {code}

    ROWNOORDERSVALUE

    110900
    211700
    312500
    413400

    {/ code}

    I have need to query which will display the cumulative difference for example I value tell 10000 numbers opening

    now I need for each of the lines of cumulative difference

    {code}

    ROWNO ORDERS DIFF

    1 10 10000 - 900 = 9100

    2 11 9100 - 700 = 8400

    3 12 8400 - 500 = 7900

    4 13 7900 - 400 = 7500

    {/ code}

    WITH commands LIKE (10 SELECT order_id, 900 double UNION ALL val
    11. SELECT, 700 FROM dual UNION ALL
    SELECT 12, 500 FROM dual UNION ALL
    Select 13, 400 double)

    SELECT row_number() over (ORDER BY order_id ASC) AS rowno
    order_id
    sum (val) 10000 - OVER (ORDER BY order_id ASC) AS diff
    orders

    /

    HTH

  • Need help with query between 2 dates

    Hello

    I did not SEE in a long time and need help with a simple query.

    I have a table of DB access with 3 fields, name, date and number

    What I want is to create a query to retrieve all the names between 2 dates

    When I ask the date field, the results are showing in this formats 2013-07-12 00:00:00

    Here's my query

    < cfquery datasource = 'mydb' name = 'test' >

    SELECT name from myTable

    where edate between ' 2011-01-01 00:00:00 ' AND ' 2013-01-01 00:00:00 '

    < / cfquery >

    < cfoutput query = 'test' >

    #name #.

    < / cfoutput >

    What I get is this error

    ODBC = 22005 (assignment error) error code

    [Microsoft] [ODBC Microsoft Access driver] Type mismatch of data in the expression of the criteria.

    Don't know what I'm doing wrong here.

    Please let me know.

    Thank you

    SELECT ename

    FROM MyTable

    WHERE edate BETWEEN

    AND

    #ename #.

  • help with query - 4 tables

    looking for help with this query. can't do things.

    4 tables.

    doc_master
    doc_folder_master
    project_master
    doc_relations

    quick overview of tables
    doc_master has all the documents in the files
    doc_folder_master has all the names of folders (documents are in folders)
    project_master has all the names of project
    doc_relations has the relationship between records and documents by file ID and ID of Document.

    try to get all the documents of the doc_master where the project name is '% provider %' I can do it without problem.
    Like this...

    Select * from document_master where proj_id IN
    (select proj_id from project_master where status = 'A' and upper (proj_title) like '% PROVIDER %')


    but now I must also name the folder in each document.

    Try like this, but does not.
    get the same name documents




    Select doc_file_name, name, proj_title from)
    Select * from
    (select * from document_master where proj_id IN)
    (select proj_id from project_master where status = 'A' and upper (proj_title) like '% PROVIDER %')
    ),

    (select * from document_relations) b.

    (select * from doc_folder_master) c,.

    (select * from project_master) d


    where a.doc_id = b.child_doc_id
    and d.proj_id = a.proj_id

    )


    I apologize if I am missing any info. If you need more please let me know.

    Published by: Jay on November 18, 2010 05:26

    So if I understand you

    select a.doc_file_name, c.name, d.proj_title
    from document_master a,
         document_relations b,
         doc_folder_master c,
         project_master d
    where c.doc_folder_id = b.parent_doc_id
      and b.child_doc_id = a.doc_id
      and d.proj_id= a.proj_id
      and d.status='A'
      and upper(d.proj_title) like '%SUPPLIER%'    
    

    If every relationship exists, the query will work.
    If not try an outer join to find the error as

    select a.doc_file_name, c.name, d.proj_title
    from document_master a,
         document_relations b,
         doc_folder_master c,
         project_master d
    where c.doc_folder_id(+) = b.parent_doc_id
      and b.child_doc_id(+) = a.doc_id
      and d.proj_id(+) = a.proj_id
    
  • Mulltiple criteria on the same column - please help with query

    Could someone help with this query?

    I have three tables-

    Table: SuperOxMap
    -------------
    ox_id
    ox_pd

    Table: SuperCPDtls
    ------------
    ox_pd
    ox_dtid

    Table: SuperPkDtls
    ------------
    ox_dtid
    ox_pkVal

    Example of SuperPkDtls-
    -------------
    ox_dtid ox_pkVal
    1 T1
    2 T2
    3 T3

    As seen above, SuperOxMap.ox_pd = SuperCPDtls.ox_pd and SuperCPDtls.ox_dtid = SuperPkDtls.ox_dtid.

    I find list of the SuperOxMap.ox_id and the SuperPkDtls.ox_pkVal where pkVal for this ox_id contains T1 and T2, but excludes the T3.

    If I put in my join query IN ("T1", "T2") and! = 'T3', which obviously do not work. I don't know how / if I can use the inner query so that he can give me all the ox_ids where associated pkVal contains T1 and T2 but would not T3 contain.

    You will appreciate all help!
  • need help with query can find data back please help.

    Hi guys I have a table such as
    CREATE TABLE "FGL"
      (
        "FGL_GRNT_CODE" VARCHAR2(60),
        "FGL_FUND_CODE" VARCHAR2(60),
        "FGL_ACCT_CODE" VARCHAR2(60),
        "FGL_ORGN_CODE" VARCHAR2(60),
        "FGL_PROG_CODE" VARCHAR2(60),
        "FGL_GRNT_YEAR" VARCHAR2(60),
        "FGL_PERIOD"    VARCHAR2(60),
        "FGL_BUDGET"    VARCHAR2(60)
      )
    and I have a data as such
    Insert into FGL (FGL_GRNT_CODE,FGL_FUND_CODE,FGL_ACCT_CODE,FGL_ORGN_CODE,FGL_PROG_CODE,FGL_GRNT_YEAR,FGL_PERIOD,FGL_BUDGET) values ('240055','240055','7600','4730','02','11','1','400');
    Insert into FGL (FGL_GRNT_CODE,FGL_FUND_CODE,FGL_ACCT_CODE,FGL_ORGN_CODE,FGL_PROG_CODE,FGL_GRNT_YEAR,FGL_PERIOD,FGL_BUDGET) values ('240055','240055','7600','4730','02','10','1','100');
    Insert into FGL (FGL_GRNT_CODE,FGL_FUND_CODE,FGL_ACCT_CODE,FGL_ORGN_CODE,FGL_PROG_CODE,FGL_GRNT_YEAR,FGL_PERIOD,FGL_BUDGET) values ('240055','240055','7240','4730','02','10','1','0');
    Insert into FGL (FGL_GRNT_CODE,FGL_FUND_CODE,FGL_ACCT_CODE,FGL_ORGN_CODE,FGL_PROG_CODE,FGL_GRNT_YEAR,FGL_PERIOD,FGL_BUDGET) values ('240055','240055','7240','4730','02','10','14','200');
    Insert into FGL (FGL_GRNT_CODE,FGL_FUND_CODE,FGL_ACCT_CODE,FGL_ORGN_CODE,FGL_PROG_CODE,FGL_GRNT_YEAR,FGL_PERIOD,FGL_BUDGET) values ('240055','240055','7600','4730','02','10','14','100');
    Insert into FGL (FGL_GRNT_CODE,FGL_FUND_CODE,FGL_ACCT_CODE,FGL_ORGN_CODE,FGL_PROG_CODE,FGL_GRNT_YEAR,FGL_PERIOD,FGL_BUDGET) values ('240055','240055','7600','4730','02','10','2','100');
    Insert into FGL (FGL_GRNT_CODE,FGL_FUND_CODE,FGL_ACCT_CODE,FGL_ORGN_CODE,FGL_PROG_CODE,FGL_GRNT_YEAR,FGL_PERIOD,FGL_BUDGET) values ('240055','240055','7470','4730','02','10','2','200');
    I need bascially to get the total of the budget column. However this is not as simple as it sounds good (at least not for the me.) totals carried forward to the new period. you will notice that you have a period column. Basically, what im is that
    fgl_grant_year 10 1 period = account 7600 its $100 and $100 for the period 2, you see $ 100 more, it wants to not be added to this is the door on the balance. that is $100.
    So im trying to write a query that basically does the following.
    IM considering a period for the sake of this example let period 1 I get anything else. I find that the greates contributes dumpster year the amount for the period 14 (which corresponds to the total of the previous year) and add it to the amount of the current year. in this case period 1 grnt_year 11
    the expected result is therefore $700
    240055     240055     7240     4730     02     10     14     200
    240055     240055     7600     4730     02     10     14     100
    240055     240055     7600     4730     02     11     1     400
    do not forget that I am not given a just a period of the year.
    any help you guys can give would be immensely appreciated. I tried to get this to work for more than 3 days now.
    Finally broke down and put together this post

    Published by: mlov83 on Sep 14, 2011 20:48

    Hello

    Thanks for posting the CREATE TABLE and INSERT statemnts; It is very useful.

    I'm not sure that understand your needs.
    The correct output will be just one line:

    TOTAL_BUDGET
    ------------
             700
    

    or will it be 3 ranks that you posted? I guess you want just line after line.

    Do you mean that you are given a period (for example, 1).
    First you have to find the largest gfl_grnt_year which is related to this period (in this case, 11).
    Then you need to add fgl_budget lines that have to be
    (1) the specific period and the largest fgl_grnt_year, or
    (2) perriod = 14 and the previous fgl_grnt_year (in this case, 10).
    Is this fair?

    If so, here's a way to do it:

    WITH     got_greatest_year     AS
    (
         SELECT     fgl.*     -- or whatever columns are needed
         ,     MAX ( CASE
                     WHEN  fgl_period = :given_period
                     THEN  fgl_grnt_year
                    END
                  ) OVER ()     AS greatest_year
         FROM     fgl
    )
    SELECT     SUM (fgl_budget)     AS total_budget     -- or SELECT *
    FROM     got_greatest_year
    WHERE     (     fgl_grnt_year     = greatest_year
         AND     fgl_period     = :given_period
         )
    OR     (     fgl_grnt_year     = greatest_year - 1
         AND     fgl_period     = 14
         )
    ;
    

    If you want the 3 lines you have posted, then change the main SELECT clause to ' SELECT * ' (or, instead of *, youcan the columns you want to see the list).

  • Need help with query of queries

    I have the query 'almost' out there, but I don't know exactly how to proceed.

    I need all of the recrods meets the criteria of the query AppliedLicense.

    But not all records will have a match in the ApprovedLicense query.

    In the MergedData query I hope to have the column with date_exp filled with ApprovedLicense data when there is a football match but NULL if there is not a match.

    The code below, of course, only returns records where there is a match in the two data sources, but I have no idea how to proceed.

    Thanks for any help.

    You could do it yourself with functions of list if I hope, you do not have too many files. After executing the second query:


    You have now 2 lists of coordinates

    Subsequently during the processing of the first query,





  • need help with query-please help

    Hi all
    I want to convert the query to a view online below. I write examples of data that I used
    create table pde(empno number(10),act_hour varchar(10 byte));
     
    Table created
     
    insert into pde values(211,'12:20');
    insert into pde values(211,'06:00');
    insert into pde values(213,'07:00');
    insert into pde values(213,'07:20');
     
    WITH  got_total_hours     AS
    (
         SELECT SUM (   TO_NUMBER (SUBSTR (act_hour, 1, 2))
                    + ( TO_NUMBER (SUBSTR (act_hour, 4, 2))
                      / 60
                      )
                    ) AS total_hours  
         from      pde
     
    )
    SELECT        TO_CHAR (FLOOR (total_hours))
           || ':'
           || TO_CHAR ( MOD (total_hours, 1) * 60
                  , 'fm00'
                   )     AS hh_mm,empno,act_hour
    FROM     got_total_hours ,pde
     
    this is the output i am getting  
     
    HH_MM  EMPNO  ACT_HOUR
    32:40     211     12:20
    32:40     211     06:00
    32:40     213     07:00
    32:40     213     07:20
    
    i tried changing the above query to an inline view given below
    SELECT        TO_CHAR (FLOOR (total_hours))
           || ':'
           || TO_CHAR ( MOD (total_hours, 1) * 60
                  , 'fm00'
                   )     AS hh_mm,act_hour from(SELECT SUM (   TO_NUMBER (SUBSTR (act_hour, 1, 2))
                    + ( TO_NUMBER (SUBSTR (act_hour, 4, 2))
                      / 60
                      )
                    ) AS total_hours  
         from      pde)
    
    ORA-00904:''ACT_HOUR":invalid identifier
    Please help me
    thanking in advance
    Kind regards
    oracleuser

    Published by: makdutakdu on January 5, 2010 11:41

    Just push "with the clause" within the main request and give an alias of the table for him... something like

     SELECT TO_CHAR (FLOOR (total_hours))
      || ':'
      || TO_CHAR ( MOD (total_hours, 1) * 60 , 'fm00' ) AS hh_mm,
      empno                                                     ,
      act_hour
       FROM
      (SELECT SUM ( TO_NUMBER (SUBSTR (act_hour, 1, 2)) + ( TO_NUMBER (SUBSTR (act_hour, 4, 2)) / 60 ) ) AS total_hours
         FROM pde
      ) got_total_hours ,
      pde
    

    Ravi Kumar

  • Need help with query for points and polygons, 2 tables of

    Hi all

    I'm slowly stumbling along trying to figure things out space.

    I have two tables, GEO_POINTS:
    (
    DEP_ID NUMBER (12) NOT NULL,
    LINE NUMBER 4 NOT NULL,.
    MDSYS. POINT_LOC SDO_GEOMETRY
    )

    and POLYGON_AREAS:
    (
    POLY_NAME VARCHAR2 (120 CHAR),
    POLY_DESC VARCHAR2 (120 CHAR),
    MDSYS POLY_POINTS. SDO_GEOMETRY
    )

    Neither table is engraved in stone, if any, I can change some structure.

    I'm trying to understand how to write a query to retrieve all the points in a polygon, perhaps even with an optional buffer provided by the user.

    Conversely, I would probably also need to know what polygons a point would have drawn in, and it's the only request I could make any progress on.

    What I have so far, which is not working properly, is the following:

    Select * from deposits_search where dep_id in)
    SELECT dep_id
    OF geo_points, polygon_areas
    where (sdo_relate)
    poly_points,
    (SELECT point_loc
    OF geo_points
    WHERE dep_id = 10282444),
    ("mask = ANYINTERACT") = "TRUE");

    In the light of the foregoing, I want to select all the lines of a third table (DEPOSITS_SEARCH), for all polygons which is a point. The DEP_ID column is my primary key for most of the data tables in the database, and the number rose in my application query. However, the above returns all rows. It should only return one, because I only have a polygon of test defined so far.

    Any help is greatly appreciated. Thank you

    Bill Ferguson

    in which case you must include a line of buffer for the interaction between the points and polygons (with a stamp),

    better, you use the SDO_WITHIN_DISTANCE operator.

    http://download.Oracle.com/docs/HTML/B14255_01/sdo_operat.htm#i77653

    Not so sure what you mean with "I always have problems while providing a point location and extract the polygons that point would be plotted in" as so-called before unless you want that as a 'transitional instance of a geometry. (Specified using a variable binding or a builder SDO_GEOMETRY.) »

    http://download.Oracle.com/docs/HTML/B14255_01/sdo_operat.htm#i78531

    Read what geometry2 means in there. Read the examples and you will see that you have the geometry second in space operator as a builder. If this is what you need.

    Luke

  • Help with query - get an ERROR: ORA-00905: lack of keyword

    Can someone help me understand what the problem with this query? Thank you

    Deanna



    Select last_name. «, » || first name
    in motor_assist2 (technician1_name)
    of org1
    where radionum =: p2_technician1_radio;

    Maybe this:

    insert into motor_assist2 (technician1_name)
    select last_name||','||first_name
    from org1
    where radionum=:p2_technician1_radio;
    
  • need help with query xmltable

    Hello team,

    I have a problem by querying the xml file. Unable to get the correct result.

    XML:

    " < = xmlns:env env:Envelope ' http://schemas.xmlsoap.org/SOAP/envelope/ "xmlns:wsa =" " http://www.w3.org/2005/08/addressing ">

    < env:Header >

    < wsa: MessageID > urn: 93D110E0D6CD11E5BF8FC7751D1F819E < / wsa: MessageID >

    < wsa: ReplyTo >

    < wsa:Address > http://www.w3.org/2005/08/addressing/anonymous < / wsa:Address >

    < / wsa: ReplyTo >

    < / env:Header >

    < env:Body >

    " < = xmlns:client retrieveSubscriberDetailResponse ' http://xmlns.Oracle.com/SBLMVNE/MVNERetrieveSubscriberDetail/MVNERetrieveSubscriberDetailProcess "xmlns =" http://xmlns.Oracle.com/SBLMVNE/MVNERetrieveSubscriberDetail/MVNERetrieveSubscriberDetailProcess ">

    < customer: header >

    < customer: InterfaceName / >

    < customer: InterfaceId / >

    < customer: CorrelationId > Interface Sync n / < / customer: CorrelationId >

    < customer: ResultCode > 0 < / customer: ResultCode >

    < customer: ResultDescription > success < / customer: ResultDescription >

    < / customer: header >

    < customer: subscribers >

    < customer: Subscriber >

    < customer: subscriberId > 3891907 < / customer: subscriberId >

    < customer: serviceNo1 > 639372000342 < / client: serviceNo1 >

    < customer: serviceNo2 / >

    < customer: serviceNo3 > 515024400960403 < / client: serviceNo3 >

    < customer: serviceNo4 >

    < / customer: Subscriber >

    < / customer: subscribers >

    < / retrieveSubscriberDetailResponse >

    < / env:Body >

    < / env:Envolope >

    Here's my query:

    Select x.* tmp_soap_data t,

    xmltable (xmlnamespaces ('http://schemas.xmlsoap.org/soap/envelope/"as"ns1","http://www.w3.org/2005/08/addressing"as"ns2", ))

                             ' ( http://xmlns.Oracle.com/SBLMVNE/MVNERetrieveSubscriberDetail/MVNERetrieveSubscriberDetailProcess ' as 'ns3'),

    ' ns1:Envelope / ns1:Body/retrieveSubscriberDetailResponse/ns3:subscribers '

    in passing t.lob_data

    path of columns subs_id varchar2 (100) ' / ns3:Subscriber / ns3:subscriberId') x;

    but the result is NULL.

    I'm on the right track with my request?

    Best regards

    Nelz Ki

    It works

    WITH tmp_soap_data as (select xmltype('
      
        
          
            
              3891907
              639372000342
              
              515024400960403
              
      
        
      
       
    ') lob_data from dual)
    -- Above is dummy setup to mimic your data tables
    select x.*
      from tmp_soap_data t,
           xmltable(xmlnamespaces('http://schemas.xmlsoap.org/soap/envelope/' as "ns1",
                                  'http://xmlns.oracle.com/SBLMVNE/MVNERetrieveSubscriberDetail/MVNERetrieveSubscriberDetailProcess' as "ns3"),
                    'ns1:Envelope/ns1:Body/ns3:retrieveSubscriberDetailResponse/ns3:subscribers/ns3:Subscriber'
                    passing t.lob_data
                    columns
                    subs_id varchar2(100) path 'ns3:subscriberId') x;
    

    You were close.

    I made several minor changes.  Been cut down XML to remove the nodes not used for readability, typos corrected in the node names, removed the namespace ns2 is not mentioned in the XPath expressions, changed XPath primary as assuming that the client node: Subscriber could repeat, changed the XPath for the subs_id accordingly noticed that the node retrieveSubscriberDetailResponse uses the same URI for two namespaces, has added the ns3 prefix to retrieveSubscriberDetailResponse in the Xpath expression since it resides is in a default namespace and prefix ns3 points to this default namespace.

  • Need help with query

    Have the rank as below,

    name of the sum

    100 A1

    -A2 200

    A3 300

    50 A1

    -A2 700

    A3 80

    10 A1

    -A2 90

    30 A3

    Need to query to extract the output like this:

    B1                     B2

    A1 + a3 (Sum) A2 (sum)

    Please help me out of this...

    Hello

    It is difficult to understand what you want... A guess based on many assumptions:

    -B1 and B2 are column headers,
    -"A1 + A3" and "A2" in the 'exit' is simply to indicate that you want the sum of the amounts for the first names.

    -Some of the AI have all their amounts > = 0, others have their amounts<=>
    -You want to make the sum of all positive numbers in the first column and all the negatives in the second column

    SELECT SUM (GREATEST (0, t.amount)) b1

    , B2 SUM (LESS (0, t.amount))

    MYTABLE t

    ;

    (I think there is only a bit of luck it's really what you want, but provide a full test case and the output that you really want and why not, try to explain / explicit rules, then we can give better help)

    Best regards

    Bruno Vroman.

Maybe you are looking for

  • New iPhone 6s 64 update for IOS 10

    Hello! I have brand new iPhone 6s 64gt IOS9. Can I update IOS10 (or is skilled to update) and then in use (load applications, to make my settings etc.)? When I phone backup, it backs up the entire phone (IOS and other things) or only my own settings

  • How to allow a port restricted?

    I'm trying to access a specific port and Firefox blocks access, https://x.x.x.x:xxxxx. This is the message: This address uses a network port that is normally used for purposes other than browsing the Web. Firefox has cancelled the request for your pr

  • Impossible to verify if the plugins are up to date

    Since May 4, 2012 about 6 hours EST (on 3 different computers) I get "sorry, we couldn't find the page or file you were looking for" when I click on the link "check to see if your plugins are up-to-date" through the page modules. It is the first time

  • I want the bios password laptop hp mini 110-1150ev

    Hi, I want the password of the bios for computer hp mini 110-1150ev My s/n is CNU935584S (fatal error... systeam healted CNU935584S)

  • BSOD on my Satellite Pro A210

    My 120 crashes during startup. It goes to error screen start screen "Windows XP", blue for about 2 seconds and then restarts. I can't reinstall as my CD drive does not work Anyone has any ideas on how to fix it? Thank you Tom Collins