Issue using the AND condition in the query.

Hi all

I need to fetch the data of a table single app_reqm based on the conditions that send me all these APP_REQ_ID where class symbol is MBA, BTECH, BBA, SENIOR SECONDARY AND SECONDARY with AND condition (i.e. When class_symbol matches all).

I wrote a query, but it does not give the correct data, as when I run for the MBA, BBA, BTECH symbol only for condition AND class then returns the data for the other symbol of the class also-

SELECT APP_REQ_ID FROM app_req where APP_REQ_ID in
(SELECT APP_REQ_ID FROM app_req WHERE class_symbol = 'MBA')
and APP_REQ_ID in
(SELECT APP_REQ_ID FROM app_req WHERE class_symbol = "BTECH")
and APP_REQ_ID in
(SELECT APP_REQ_ID FROM app_req WHERE class_symbol = "BBA")
and APP_REQ_ID in
(SELECT APP_REQ_ID FROM app_req WHERE class_symbol = 'MAIN SCHOOL')
and APP_REQ_ID in
(SELECT APP_REQ_ID FROM app_req WHERE class_symbol = "SECONDARY")

Kindly help me.
Thanks in advance for your time and look forward to it.

This should do what you want:

SELECT b.app_req_id,
       b.student_name
FROM  (SELECT a.app_req_id,
              a.student_name,
              COUNT(DISTINCT a.class_symbol) OVER (PARTITION BY student_name) cnt
       FROM   app_req a
       WHERE  a.class_symbol IN ('MBA', 'BTECH', 'BBA', 'SENIOR SECONDARY', 'SECONDARY')) b
WHERE  b.cnt = 5

Tags: Database

Similar Questions

  • Inserting data by using the query

    Hello

    In a book, I read the Sub statement:

    Inserting data by using the query (DML)

    If the user wants to transfer data from a table to another table in the insert statement are used independently of data that can be processed or not processed form.

    Can someone clarify what is the significance of this (processed or unprocessed form).


    Thank you.

    Why don't you ask the author of the book.

    How can we know what the author means when you take a quote out of context and don't provide any reference so that we can see exactly what is shown to you.

    I can only imagine that they are referring to data that are queried directly, "like what", another table, or who was interrogated and manipulated before be inserted.

  • the search for empty cells by using the query designer

    Hello

    I'm trying to exclude empty cells in a field (by using the Query Builder), and I did:

    xDocumentSource < match > "CDL".

    < AND >

    < NOT > (xRelatedMsgid < match > "" "")

    but it does not work. I tried "NULL", but it does not work either. Could someone tell me how to do it (or where I can find examples of queries).

    Kind regards

    Iwona

    https://blogs.Oracle.com/Kyle/entry/searching_for_null_values_ucm

  • Using the QUERY parameter in exp/expdp

    Hi, I've faced a nite last question.
    IM currently using Oracle 10 g (10.2.0.4) OS - MS Windows Server 2003

    I want a dump of tables to export multiple schemas. say (acb.m1, pqr.b2, xyz.b1)

    Each table has a minimum lines of 2,000,000,

    And I want to just the initials 10 rows in each table of export

    Is it possible that I can do this...

    Please answer.
    Thanks in advance

    Export tables in multiple schemas is not supported in Data Pump until 11.1.0.7. So if you're on 10g, you will need to run multiple commands expdp. For only 10 lines of each table, use the query parameter

    Query = "where rownum"<>

    This will apply to all the tables you export.

    I hope this helps.

    Dean

    Published by: Dean WINS January 30, 2012 08:42

  • Not able to change the password by using the query. Select APPS.fnd_web_sec

    Not able to change the password by using the query.
    Select APPS.fnd_web_sec.change_password ('username', 'password') 'RES' double;

    Can someone tell why and what privileges and subsidies have flexibility to the user non-apps while it can change the password using fnd_web_sec.change_password.



    Concerning

    the information above does not solve my problem, I get the message

    Because you do not have permission on all objects that are referenced by the API (see below).

    Select FND_WEB_SEC. CHANGE_PASSWORD ('MARSHAD', 'mohammad @123') "RES" of the double

    *

    ERROR on line 1:

    ORA-00942: table or view does not exist

    ORA-06512: at the 'APPS '. FND_CORE_LOG', line 25

    ORA-06512: at the 'APPS '. FND_CORE_LOG', line 432

    ORA-06512: at the 'APPS '. FND_PROFILE', line 110

    ORA-06512: at the 'APPS '. FND_SSO_MANAGER", line 227

    ORA-06512: at the 'APPS '. FND_WEB_SEC', line 1425

    ORA-06512: at line 1...

    can you please list me what are the grants and other Jules Destrooper I should give to a user so that he can change password.

    I don't have the list of objects and you should get yourself by consulting the site code and eTRM API.

    by changing the DDT in the user non-apps after the grant, will, it may be able to change the password.please tell this syntax is correct or not.
    Select applications. FND_WEB_SEC. CHANGE_PASSWORD ('user', 'pwd') "RES" of the double

    What is the point of using 'FND_WEB_SEC. CHANGE_PASSWORD' and not FNDCPASS or FND_USER_PKG API?

    Thank you
    Hussein

  • DataPump import by using the query

    Hello

    I need to import data by filtering using the query. can anyone help?

    Thank you

    Hello
    example of

    expdp HR/hr = emp QUERY:'"WHERE dept_id > 10 AND sal > 10000"' NOLOGFILE = y DIRECTORY = dpump_dir1 DUMPFILE = exp1.dmp

    Impdp HR/hr DIRECTORY = dpump_dir1 DUMPFILE = expfull.dmp QUERY = departments:'WHERE department_id «»< 120"'="" nologfile="">

    See this link

    http://download.Oracle.com/docs/CD/B13789_01/server.101/b10825/dp_import.htm

  • IMPDP | Possible using the query option

    HI PPL,

    I wanted to know if IMPDP is possible by using the query option, as I took full expdp dump of the mentioned table and want to import only select lines.

    Impdp arup/arup directory = demo_dir dumpfile = employees.dmp
    Query = employees:------"" where salary\ > 10000\ order of salary "tables used ="

    version: 10 gr 2
    platform: UNIX

    concerning

    Obviously, it will be slow if you are using the query option, because IMPDP must import only the data that meets the criteria; It of why we export only limited data (one or two tables as needed) and import them completely.

    Concerning
    Girish Sharma

  • Problem in the export using the QUERY functionality

    Problem in the export using the QUERY functionality


    I'm trying to export some rows in a table using the query functionality
    and I have some errors... I'm using the syntax is

    system@orcl QUERY = scott.emp expdp: '"WHERE emp_no = 123455" '
    DIRECTORY = data_pump_dir DUMPFILE = data_pump.dmp
    LOGFILE = data_pump_12345.log INDEX = n

    Can someone tell me please the problem with that statement

    I also tried to use the simple export

    exp file system@orcl = orcl_export.dmp log = orcl_export.log
    tables = Scott.EMP index = QUERY = n------"WHERE emp_no\ = 123455\"

    and this error

    EXP-00008: ORACLE error 904
    ORA-00904: identify invalid

    My os is Solaris
    Please let me know what the problem

    Hello

    Try to create parfile and use that, otherwise, you will need to escape each clause correctly to run exp or expdp successfully.

    test.par

    tables=emp
    query="WHERE emp_no=123455"
    
    or
    tables=myobjects
    query="WHERE owner='SYS'"
    
    $> exp username/password parfile=test.par
    
    Export: Release 10.2.0.1.0 - Production on Thu Mar 19 10:17:48 2009
    
    Copyright (c) 1982, 2005, Oracle.  All rights reserved.
    
    Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
    With the Partitioning, OLAP and Data Mining Scoring Engine options
    Export done in WE8MSWIN1252 character set and AL16UTF16 NCHAR character set
    
    About to export specified tables via Conventional Path ...
    . . exporting table                      MYOBJECTS      22650 rows exported
    Export terminated successfully without warnings.
    

    Concerning

    Published by: OrionNet on March 19, 2009 10:21

  • List of virtual machines in TIME using the query service

    Someone been able to use the query service to produce a range of virtual machines in a paralytic? I don't see all the attributes on the VclQueryadminVMField that reference the vApp.

    I log in the org of system.

    Any help would be appreciated.

    Name of the action: getVAppVms

    Entry: VAPP (vCloud:VApp)

    Output: Array / vCloud:VM

    Script:

    var vcdHost = vApp.getHost();
    var vms = new Array();
    
    var queryService = vcdHost.getQueryService();
    expression = new VclExpression(VclQueryVMField.CONTAINER, vApp.getReference().href, VclExpressionType.EQUALS);
    filter = new VclFilter(expression);
    params = new VclQueryParams();
    params.setFilter(filter);
    
    var resultSet = queryService.queryRecords(VclQueryRecordType.VM, params);
    while (resultSet != null) {
        var records = resultSet.getRecords(new VclQueryResultVMRecord());
        System.log(records.length + " VM records found");
        for each (var record in records) {
         var vmRef = new VclReference();
         vmRef.href = record.href;
         vmRef.name = record.name;
         vmRef.type = record.type;
         vms.push(vcdHost.getEntityByReference(VclEntityType.VM, vmRef));
        }
        resultSet = resultSet.getNextPage();
    }
    
    return vms;
    

    This is what made our team (more precisely - Christophe)

  • Issue using the presentation as filter condition variable in reports

    Hello

    I have a problem using the variable presentation as a condition of filter in my reports, the details are the following:

    Details:
    --------------
    We want to implement the Max and Min variable through variable presentation only.we are unwilling to apply it in this case through session variables.
    We have two variables MIN and MAX to be used as Variables of presentation, to a column of the report (which is a quantity), so that the user wants to see the data in this column in a particular range.i.e the Min and the Max.This part was well put in place. The question is when the user wants to see comprehensive data. In this case we will spend not all values of these two variables of presentation or in other words we do not limit the data in the report so we do not any value to the variables, it's when the report is throwing the error. We want to leave this empty variables in this case.but is in error.

    Please suggest how can I overcome this problem.


    Thanks in advance.

    Kind regards
    Praveen

    Hello
    Don't forget to assign points before closing the thread

    Thank you
    saichand.v

  • Performance issue with the query when join OKS and tables of the IB

    Hello

    I'm developing an integration for the automation of RMA through repair. The type of repair order is based on the details of the guarantee. This check must be made for each record.

    Request for detailed below, I wrote, but it of a long way and slows down my program. Without this validation, it works perfectly.

    The problem is the join of tables with OKS IB, he kills performance. I also try to my side,

    any suggestion or help is appreciated. Here's the query in the program:

    SELECT DISTINCT (TYPE |) '-' || service | '-' || status)

    IN v_war_details

    FROM (SELECT TO_NUMBER (linesb.line_number) line,

    DECODE

    (fnd_profile. VALUE

    ('OKS_LINE_MIRR_NAME_OR_DESC'),

    'DISPLAY_NAME', sysitems.concatenated_segments,

    "DISPLAY_DESC", sysitems.description

    ) service.

    linestyletl.NAME TYPE,

    status of ststl.meaning,

    start_date linesb.start_date,

    linesb.end_date end_date,

    oks_misc_util_web.duration_period

    (linesb.start_date,

    linesb.end_date

    ) DURATION OF,.

    TimeUnit.unit_of_measure_tl period

    Of okc_k_lines_b linesb,.

    okc_k_lines_tl linestl,

    okc_line_styles_b linestyleb,

    okc_line_styles_tl linestyletl,

    okc_k_headers_all_b hdr,

    oks_k_lines_b slines,

    okc_k_items kitems,

    mtl_system_items_b1_kfv sysitems,

    okc_statuses_b stsb,

    okc_statuses_tl ststl,

    mtl_units_of_measure_tl timeunit,

    okc_lookups_v rentype,

    Glu mtl_units_of_measure_tl

    WHERE linesb.cle_id IS NULL

    AND linesb.ID = linestl.ID

    AND linestl. LANGUAGE = USERENV ("LANG")

    AND linesb.lse_id = linestyleb.ID

    AND linesb.lse_id (1, 12, 14, 19, 46)

    AND linestyleb.ID = linestyletl.ID

    AND linestyletl. LANGUAGE = USERENV ("LANG")

    AND linesb.chr_id = hdr.ID

    AND linesb.ID = slines.cle_id

    AND linesb.ID = kitems.cle_id

    AND kitems.object1_id1 =

    SysItems.inventory_item_id

    AND kitems.object1_id2 =

    SysItems.organization_id

    AND kitems.uom_code = uom.uom_code (+)

    AND unit of measure. LANGUAGE (+) = USERENV ("LANG")

    AND linesb.sts_code = stsb.code

    AND stsb.code = ststl.code

    AND ststl. LANGUAGE = USERENV ("LANG")

    AND timeunit.uom_code =

    oks_misc_util_web.duration_unit

    (linesb.start_date,

    linesb.end_date

    )

    AND timeunit. LANGUAGE = USERENV ("LANG")

    AND linesb.line_renewal_type_code = rentype.lookup_code (+)

    AND rentype.lookup_type (+) =

    'OKC_LINE_RENEWAL_TYPE '.

    AND (IN) hdr.ID

    SELECT kh.ID

    Of okc_k_headers_all_b kh.

    okc_k_lines_b kl,

    Ki okc_k_items,

    okc_line_styles_v ks,

    csi_item_instances c,

    mtl_system_items_b I have

    WHERE kh.org_id = p_org_id

    AND c.instance_id = p_instance_id

    AND c.serial_number = p_serial_num

    AND i.inventory_item_id =

    p_inventory_item_id

    AND kh.contract_number_modifier IS NULL

    -can be filled

    AND kh.ID = kl.dnz_chr_id

    AND kh.ID = ki.dnz_chr_id

    AND kl.ID = ki.cle_id

    AND kl.lse_id = ks.ID

    AND IN ki.jtot_object1_code

    ("OKX_CUSTPROD")

    AND c.last_vld_organization_id =

    i.organization_id

    AND TO_NUMBER (ki.object1_id1) =

    c.INSTANCE_ID

    AND c.inventory_item_id =

    i.inventory_item_id))

    Service = 'GUARANTEE '.

    AND TRUNC (SYSDATE) BETWEEN start_date AND end_date;

    Not sure where it would be so I put it in the section SQL/PLSQL.

    Kind regards

    Prashant

    Found the solution

    AND TO_NUMBER (ki.object1_id1) = c.instance_id

    replaced by to_char (c.instance_id) = ki.object1_id1 AND

  • Slow index by using the query. Fast with full table Scan.

    Salvation;

    (Thanks for the links)

    Here's my question correctly formatted.

    The query:
    SELECT count(1)
    from ehgeoconstru  ec 
    where ec.TYPE='BAR'  
    AND ( ec.birthDate <= TO_DATE('2009-10-06 11:52:12', 'YYYY-MM-DD HH24:MI:SS') )   
    and deathdate is null 
    and substr(ec.strgfd, 1, length('[CIMText')) <> '[CIMText'
    Works on 32 seconds!


    Same query, but with an extra where clause:
    SELECT count(1)
    from ehgeoconstru  ec 
    where ec.TYPE='BAR'  
    and  ( (ec.contextVersion = 'REALWORLD')     --- ADDED HERE
    AND ( ec.birthDate <= TO_DATE('2009-10-06 11:52:12', 'YYYY-MM-DD HH24:MI:SS') ) )  
    and deathdate is null 
    and substr(ec.strgfd, 1, length('[CIMText')) <> '[CIMText'
    This is 400 seconds.

    It should return data from a table, given the conditions.

    The database version is Oracle9i Release 9.2.0.7.0

    These are the parameters relevant for the optimizer:
    SQL> show parameter optimizer
    
    NAME                                 TYPE        VALUE
    ------------------------------------ ----------- ------------------------------
    optimizer_dynamic_sampling           integer     1
    optimizer_features_enable            string      9.2.0
    optimizer_index_caching              integer     99
    optimizer_index_cost_adj             integer     10
    optimizer_max_permutations           integer     2000
    optimizer_mode                       string      CHOOSE
    
    SQL> 
    Here is the output of the PLAN to EXPLAIN for the first quick query:
    PLAN_TABLE_OUTPUT
    --------------------------------------------------------------------------------
    
    --------------------------------------------------------------------------------
    | Id  | Operation                     |  Name               | Rows  | Bytes | Cost  |
    --------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT     |                         |           |       |       |
    |   1 |  SORT AGGREGATE       |                         |           |       |       |
    |*  2 |   TABLE ACCESS FULL   | EHCONS            |       |       |       |
    --------------------------------------------------------------------------------
    
    Predicate Information (identified by operation id):
    ---------------------------------------------------
    
    PLAN_TABLE_OUTPUT
    --------------------------------------------------------------------------------
    
       2 - filter(SUBSTR("EC"."strgfd",1,8)<>'[CIMText' AND "EC"."DEATHDATE"
                  IS NULL AND "EC"."BIRTHDATE"<=TO_DATE('2009-10-06 11:52:12', 'yyyy
    -mm-dd
    
                  hh24:mi:ss') AND "EC"."TYPE"='BAR')
    
    Note: rule based optimization
    Here is the output of the EXPLAIN of PLAN for slow queries:
    PLAN_TABLE_OUTPUT
    --------------------------------------------------------------------------------
       |       |
    
    |   1 |  SORT AGGREGATE              |                             |       |
       |       |
    
    |*  2 |   TABLE ACCESS BY INDEX ROWID| ehgeoconstru      |       |
       |       |
    
    |*  3 |    INDEX RANGE SCAN          | ehgeoconstru_VSN  |       |
       |       |
    
    
    PLAN_TABLE_OUTPUT
    --------------------------------------------------------------------------------
    Predicate Information (identified by operation id):
    ---------------------------------------------------
    2 - filter(SUBSTR("EC"."strgfd",1,8)<>'[CIMText' AND "EC"."DEATHDATE" IS
     NULL AND "EC"."TYPE"='BAR')
    
    PLAN_TABLE_OUTPUT
    --------------------------------------------------------------------------------
       3 - access("EC"."CONTEXTVERSION"='REALWORLD' AND "EC"."BIRTHDATE"<=TO_DATE('2
    009-10-06
    
                  11:52:12', 'yyyy-mm-dd hh24:mi:ss'))
           filter("EC"."BIRTHDATE"<=TO_DATE('2009-10-06 11:52:12', 'yyyy-mm-dd hh24:
    mi:ss'))
    
    
    Note: rule based optimization
    The TKPROF output for this slow statement is:
    TKPROF: Release 9.2.0.7.0 - Production on Tue Nov 17 14:46:32 2009
    
    Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.
    
    Trace file: gen_ora_3120.trc
    Sort options: prsela  exeela  fchela  
    ********************************************************************************
    count    = number of times OCI procedure was executed
    cpu      = cpu time in seconds executing 
    elapsed  = elapsed time in seconds executing
    disk     = number of physical reads of buffers from disk
    query    = number of buffers gotten for consistent read
    current  = number of buffers gotten in current mode (usually for update)
    rows     = number of rows processed by the fetch or execute call
    ********************************************************************************
    
    SELECT count(1)
    from ehgeoconstru  ec
    where ec.TYPE='BAR'
    and  ( (ec.contextVersion = 'REALWORLD')
    AND ( ec.birthDate <= TO_DATE('2009-10-06 11:52:12', 'YYYY-MM-DD HH24:MI:SS') ) )
    and deathdate is null
    and substr(ec.strgfd, 1, length('[CIMText')) <> '[CIMText'
    
    call     count       cpu    elapsed       disk      query    current        rows
    ------- ------  -------- ---------- ---------- ---------- ----------  ----------
    Parse        1      0.00       0.00          0          0          0           0
    Execute      1      0.00       0.00          0          0          0           0
    Fetch        2      0.00     538.12     162221    1355323          0           1
    ------- ------  -------- ---------- ---------- ---------- ----------  ----------
    total        4      0.00     538.12     162221    1355323          0           1
    
    Misses in library cache during parse: 0
    Optimizer goal: CHOOSE
    Parsing user id: 153  
    
    Rows     Row Source Operation
    -------  ---------------------------------------------------
          1  SORT AGGREGATE 
      27747   TABLE ACCESS BY INDEX ROWID OBJ#(73959) 
    2134955    INDEX RANGE SCAN OBJ#(73962) (object id 73962)
    
    ********************************************************************************
    
    alter session set sql_trace=true
    
    
    call     count       cpu    elapsed       disk      query    current        rows
    ------- ------  -------- ---------- ---------- ---------- ----------  ----------
    Parse        0      0.00       0.00          0          0          0           0
    Execute      1      0.00       0.02          0          0          0           0
    Fetch        0      0.00       0.00          0          0          0           0
    ------- ------  -------- ---------- ---------- ---------- ----------  ----------
    total        1      0.00       0.02          0          0          0           0
    
    Misses in library cache during parse: 0
    Misses in library cache during execute: 1
    Optimizer goal: CHOOSE
    Parsing user id: 153  
    
    
    
    ********************************************************************************
    
    OVERALL TOTALS FOR ALL NON-RECURSIVE STATEMENTS
    
    call     count       cpu    elapsed       disk      query    current        rows
    ------- ------  -------- ---------- ---------- ---------- ----------  ----------
    Parse        1      0.00       0.00          0          0          0           0
    Execute      2      0.00       0.02          0          0          0           0
    Fetch        2      0.00     538.12     162221    1355323          0           1
    ------- ------  -------- ---------- ---------- ---------- ----------  ----------
    total        5      0.00     538.15     162221    1355323          0           1
    
    Misses in library cache during parse: 0
    Misses in library cache during execute: 1
    
    
    OVERALL TOTALS FOR ALL RECURSIVE STATEMENTS
    
    call     count       cpu    elapsed       disk      query    current        rows
    ------- ------  -------- ---------- ---------- ---------- ----------  ----------
    Parse        0      0.00       0.00          0          0          0           0
    Execute      0      0.00       0.00          0          0          0           0
    Fetch        0      0.00       0.00          0          0          0           0
    ------- ------  -------- ---------- ---------- ---------- ----------  ----------
    total        0      0.00       0.00          0          0          0           0
    
    Misses in library cache during parse: 0
    
        2  user  SQL statements in session.
        0  internal SQL statements in session.
        2  SQL statements in session.
    ********************************************************************************
    Trace file: gen_ora_3120.trc
    Trace file compatibility: 9.02.00
    Sort options: prsela  exeela  fchela  
           2  sessions in tracefile.
           2  user  SQL statements in trace file.
           0  internal SQL statements in trace file.
           2  SQL statements in trace file.
           2  unique SQL statements in trace file.
          94  lines in trace file.
    Published by: PauloSMO on November 17, 2009 04:21

    Published by: PauloSMO on November 17, 2009 07:07

    Published by: PauloSMO on November 17, 2009 07:38 - title changed to be more correct.

    Although your optimizer_mode is choosing, it seems that there are no statistics collected on ehgeoconstru. The absence of estimated costs and estimated row counts of each of the stages of the plan and the "Note: optimization based on rules" at the end of these two plans would tend to confirm this.

    Optimizer_mode choose means that if statistics are collected then it will use the CBO, but if no statistic is present in any of the tables in the query, the optimizer to rule will be used. The RBO tends to be happy in the best of the index case. I guess the index ehgeoconstru_VSN contextversion as the main column and also includes the date of birth.

    You can either gather statistics on the table (if all other tables have statistics) using dbms_stats.gather_table_stats, or suggest the query to use a full scan instead of index. Another solution would be to apply a function or an operation against the contextversion to prevent the use of the index. something like this:

    SELECT COUNT(*)
    FROM ehgeoconstru  ec
    WHERE ec.type='BAR' and
          ec.contextVersion||'' = 'REALWORLD'
          ec.birthDate <= TO_DATE('2009-10-06 11:52:12', 'YYYY-MM-DD HH24:MI:SS') and
          deathdate is null and
          SUBSTR(ec.strgfd, 1, LENGTH('[CIMText')) <> '[CIMText'
    

    or maybe UPPER (ec.contextVersion) so that would not change the rows returned.

    John

  • Using the query - amount weekly, daily, max &amp; time

    Hi guys,.

    I came looking for help with this query, I should use to create a new table. At first I just thought I needed to store the weekly amount and some other information, but then told me that I need the sum for the week and the hourly figure higher this week with time. I managed to make all columns except rush hour causing me issues.

    The DESC table is as follows: http://i38.tinypic.com/8yt0.png

    My query result has need of the following:
    Db_name (direct copy of the table)
    TYPE (direct copy of the table)
    YEAR (cropped from TD_HR - first 4 characters)
    WEEK (cropped from TD_HR and then converted to the IW format)
    TOTAL (weekly column TOTAL amount)
    HOURLY_PEAK (the largest AMOUNT for a given time during a week)
    PEAK_TIME (time of the highest sum for the week)

    I have everything show except PEAK_TIME. Sample data:
    DB_NAME     TD_HR             TOTAL   TYPE
    CSAHEPA     2008-07-24 16     35     CON
    CSAHEPA     2008-07-24 15     4     CON
    CSAHEPA     2008-07-24 16     19     CON
    CSAHEPA     2008-07-24 17     3651     CON
    CSAHEPA     2008-07-24 16     7     CON
    CSAHEPA     2008-07-24 17     113     CON
    CSAHEPA     2008-07-24 17     534     CON
    CSAHEPA     2008-07-24 17     289     CON
    CSAHEPA     2008-07-24 17     12     CON
    CSAHEPA     2008-07-24 16     52     CON
    My current (terribly inefficient) query is the following:
    select DB_NAME, YEAR, WEEK, sum(SUM), TYPE, sum(WEEKLY_PEAK) from (
    select DB_NAME, SUBSTR(TD_HR, 1, 4) year, to_char(to_date(SUBSTR(TD_HR, 1, 10), 'RRRR-MM-DD'), 'IW') week, sum(TOTAL) sum, TYPE, 0 WEEKLY_PEAK
    from CORCON01_HOUR_CHG_TOTALS
    group by DB_NAME, SUBSTR(TD_HR, 1, 4), to_char(to_date(SUBSTR(TD_HR, 1, 10), 'RRRR-MM-DD'), 'IW'), TYPE
    union all
    select db_name, year, week, 0 sum, type, max(peak) weekly_peak from (
    select DB_NAME, SUBSTR(TD_HR, 1, 4) year, to_char(to_date(SUBSTR(TD_HR, 1, 10), 'RRRR-MM-DD'), 'IW') week, TYPE, sum(total) peak, CONCAT(INITCAP(TO_CHAR(TO_DATE(rpad(td_hr, 10),'yyyy-mm-dd'),'dy')), substr(td_hr,11))||':00' peak_time
    from CORCON01_HOUR_CHG_TOTALS
    group by DB_NAME, SUBSTR(TD_HR, 1, 4), to_char(to_date(SUBSTR(TD_HR, 1, 10), 'RRRR-MM-DD'), 'IW'), TYPE, CONCAT(INITCAP(TO_CHAR(TO_DATE(rpad(td_hr, 10),'yyyy-mm-dd'),'dy')), substr(td_hr,11)))
    group by db_name, year, week, type)
    group by db_name, year, week, type
    The final column data are given in the 2nd query here as:
    CONCAT (INITCAP (TO_CHAR (TO_DATE (rpad (td_hr, 10), "yyyy-mm-dd"), "dy")), substr(td_hr,11)) |': 0 0' peak_time
    Any help (get the last column included and/or improvement of the effectiveness of the query) is greatly appreciated.

    Mike

    This?

    with  results as (select db_name,
                             to_date(td_hr, 'yyyy-mm-dd hh24') td_hr,
                             total,
                             type
                      from   CORCON01_HOUR_CHG_TOTALS),
    final_results as (select db_name,
                             td_hr,
                             type,
                             sum(total) sum_total
                      from   results
                      group by db_name,
                               td_hr,
                               type)
    select db_name,
           to_char(td_hr, 'yyyy') year,
           to_char(td_hr, 'iw') week,
           type,
           sum(sum_total) week_sum_total,
           max(sum_total) peak_sum_total,
           to_char(max(td_hr) keep (dense_rank first order by sum_total desc), 'yyyy-mm-dd hh24') peak_hour
    from   final_results
    group by db_name,
             to_char(td_hr, 'yyyy'),
             to_char(td_hr, 'iw'),
             type;
    
    DB_NAME          YEAR WEEK TYPE       WEEK_SUM_TOTAL PEAK_SUM_TOTAL PEAK_HOUR
    ---------------- ---- ---- ---------- -------------- -------------- -------------
    CSAHEPA          2008 30   CON                  4716           4599 2008-07-24 17
    CSAHEPA          2008 39   CON                   611            555 2008-09-24 16
    

    (And why, oh why, you store your dates as VARCHAR2?) ({noformat} * sobs * {noformat})

  • Using the query to get the group by rollup subtotal

    Hello

    Expected output is, for 'chris' each record must have subtotal row because it has different 'no' of the column values.

    For 'John' the subtotal came as planned because she didn't even.

    Could you please correct the query for "chris" below!

     select   
    case when nm is null then 'Total'  
         when no is null then 'Subtotal'  
         else nm  
    end nm,no,emplmt,profund,status,dt,sal,days,intrst,intrs1,intrs2  
    from   
    (  
        with t as     
            (select 'chris' nm , 10 no ,'FT' Emplmt, 'PF' ProFund , 'Reg' Status ,to_Date ('01/22/2014','mm/dd/yyyy') dt , 2456 sal, 10 days , 50 intrst ,55 intrs1 ,60 intrs2 from dual    
            union all    
            select 'chris' nm , 20 no ,'FT' Emplmt, 'PF' ProFund , 'Reg' Status ,to_Date ('01/03/2014','mm/dd/yyyy') dt , 1000 sal, 30 days , 50 intrst ,55 intrs1 ,60 intrs2 from dual    
            union all    
            select 'chris' nm , 30 no ,'FT' Emplmt, 'PF' ProFund , 'NonReg' Status ,to_Date ('01/01/2014','mm/dd/yyyy') dt , 20 sal, -5 days , 1 intrst ,1 intrs1 ,1 intrs2 from dual    
           union all
           select 'john' nm , 11 no ,'PT' Emplmt, 'PF' ProFund , 'Reg' Status ,to_Date ('05/02/2014','mm/dd/yyyy') dt , 1153 sal, 10 days , 50 intrst ,55 intrs1 ,60 intrs2 from dual    
            union all    
            select 'john' nm , 11 no ,'PT' Emplmt, 'PF' ProFund , 'Reg' Status ,to_Date ('05/16/2014','mm/dd/yyyy') dt , 1000 sal, 8 days , 40 intrst ,45 intrs1 ,50 intrs2 from dual    
    
    
           )    
        select nm,no,emplmt,profund,status,dt,sum(sal)sal,sum(days)days,sum(intrst)intrst,sum(intrs1)intrs1,sum(intrs2)intrs2  
        from t  
        GROUP BY ROLLUP (nm,no,emplmt,profund,status,dt)  
        order by nm,no,emplmt,profund,status,dt  
    )  
    where (no is not null and emplmt is not null and profund is not null and status is not null and dt is not null)  
    or (no is null and emplmt is null and profund is null and status is null and dt is null)  
    

    allows us to use grouping sets to produce just the totals you want.

    with t as

    (select "chris" nm1, 10 no1, "Pi" Emplmt, "PF" ProFund "Reg" Status, to_Date (January 22, 2014 "," mm/dd/yyyy") dt, 2456 sal, 10 days, 50 intrst, intrs1 55 intrs2 60 double)

    Union of all the

    Select No, the "chris" nm, 20 'ft' Emplmt, "PF" ProFund "Reg" Status, to_Date (3 January 2014 "," mm/dd/yyyy") dt, intrst 50, intrs1 55, 1000 sal, 30 days, 60 intrs2 of the double

    Union of all the

    Select "chris" nm, 30 no, "Pi" Emplmt, ProFund "PF", "NonReg" State, to_Date (January 1, 2014 "," mm/dd/yyyy") dt, 20 sal,-5 days, 1 intrst, 1 intrs1, 1 intrs2 of the double

    Union of all the

    Select "Jean" nm, 11 no, "PT" Emplmt, "PF" ProFund "Reg" Status, to_Date (May 2, 2014 "," mm/dd/yyyy") dt, 1153 sal, 10 days, 50 intrst, intrs1 55 intrs2 60 double

    Union of all the

    Select "Jean" nm, 11 no, "PT" Emplmt, "PF" ProFund "Reg" Status, to_Date (16 may 2014 "," mm/dd/yyyy") dt, 1000 sal, 8 days, intrst 40, 45 intrs1, 50 intrs2 of the double

    )

    SELECT

    CASE

    WHEN grouping (nm1) = 1

    THEN "Total".

    WHEN grouping (emplmt) = 1

    THEN "Subtotal".

    Of ANOTHER nm1

    END nm,

    CASE

    WHEN grouping (emplmt) = 1

    THEN NULL

    Of ANOTHER no1

    END no emplmt, profund, status, dt, sal SUM (sal), SUM (days) days, SUM (intrst) intrst, SUM (intrs1) intrs1, intrs2 SUM (intrs2)

    T

    GROUP BY Grouping SETS ((), (nm1, no1), (nm1, no1, emplmt, profund, status, dt))

    ORDER BY nm1, no1, emplmt, profund, status, dt

    NM               NO EM PR STATUS DT              SAL       DAYS     INTRST     INTRS1     INTRS2 chris            10 FT PF Reg    22.01.14       2456         10         50         55         60 Subtotal                                        2456         10         50         55         60chris            20 FT PF Reg    03.01.14       1000         30         50         55         60 Subtotal                                        1000         30         50         55         60chris            30 FT PF NonReg 01.01.14         20         -5          1          1          1 Subtotal                                          20         -5          1          1          1john             11 PT PF Reg    02.05.14       1153         10         50         55         60 john             11 PT PF Reg    16.05.14       1000          8         40         45         50Subtotal                                        2153         18         90        100        110 Total                                           5629         53        191        211        231 
    
  • Issue using the ENGINE table MEMORY SUNOPSIS (high priority)

    Hi gurus,

    It is to launch an operator, like any error by using the SUNOPSIS MEMORY ENGINE to generate a .csv file using the database as a source table.

    ODI-1228: SrcSet0 (load) task fails on the target connection SUNOPSIS ENGINE table SUNOPSIS MEMORY ENGINE.
    Caused by: java.sql.SQLException: unknown token

    (LKM used: LKM Sql to Sql.)
    IKM used: IKM Sql to add files.)

    can you please help me about this ASAP so that it became a show-stopper for me to go further.

    Any help will be greatly appreciated.

    Thank you very much
    Pavan

    Published by: Pavan. on July 11, 2012 10:22

    Hi all

    The issue has been resolved successfully.

    The solution is
    We need to change the E$ _, I have$ _, J$ _,... E_, I_ , J_... ((c'est à dire, enlever le symbole '$')) in the PHYSICAL SCHEMA of ENGINE table SUNOPSIS MEMORY according to the information provided below.

    When interfaces running and using an XML schema or file complex as the transit area, the 'Unknown token' error. This error is caused by the HSQL (2.0) updated version. This new version of HSQL requires that the names of tables that contains a dollar sign ($) are enclosed in quotes. Temporary tables (loading, integration, etc.) that are created by the knowledge Modules do not respect this requirement on the technologies of complex and HSQL records.

    To work around the problem, change the physical schema definitions to remove the dollar symbol ($) of all paintings of prefixes work. Scenarios must be regenerated with these new settings.

    It has worked well for me.

    Thank you
    Pounet

Maybe you are looking for