Nested Select statement

Hello

Is it possible to write a select statement that is nested in the form of oracle?
the query I'm putting runs a TOAD all its giving me an error when I compile it in the form...
Encountered the symbol "SELECT" when expecting one of the following....
My request is something like:
        SELECT  COL1 -- SELECT #1
        INTO      V_COL
        FROM    TB1,
                      TB2,
                      TB3
        
        WHERE   -- CONDITION 1
        AND        -- CONDITION 2
        AND     NVL((   
                        SELECT #2
            
                        UNION 
            
                        SELECT #3
                ),VAL)) BETWEEN VAL1 AND VAL2
Thank you very much.

HST,

Try the code below.

SELECT NVL(PCF.CTR_INFORMATION1, 'NO_CONTACT') INTO V_TYPE
FROM PER_PEOPLE_F PAPF, PER_ALL_ASSIGNMENTS_F PAAF, PER_CONTRACTS_F PCF,
(
SELECT TRUNC(SYSDATE) CHK_DATE FROM PER_PERSON_TYPE_USAGES_V PPTU WHERE PPTU.PERSON_TYPE_ID = PAPF.PERSON_TYPE_ID AND PPTU.PERSON_ID = PAPF.PERSON_ID AND PPTU.USER_PERSON_TYPE = 'Employee'
UNION
SELECT MAX(PASF_TER.EFFECTIVE_END_DATE) CHK_DATE FROM PER_PERSON_TYPE_USAGES_V PPTU, PER_ALL_ASSIGNMENTS_F PASF_TER WHERE PPTU.PERSON_TYPE_ID = PAPF.PERSON_TYPE_ID AND PASF_TER.PERSON_ID = PPTU.PERSON_ID AND PPTU.PERSON_ID = PAPF.PERSON_ID AND PPTU.USER_PERSON_TYPE = 'Ex-employee' HAVING MAX(PASF_TER.EFFECTIVE_END_DATE) IS NOT NULL
) CON
WHERE TRUNC(SYSDATE) BETWEEN PAPF.EFFECTIVE_START_DATE AND PAPF.EFFECTIVE_END_DATE
AND PAPF.PERSON_ID = PAAF.PERSON_ID AND NVL(CON.CHK_DATE, SYSDATE) BETWEEN PAAF.EFFECTIVE_START_DATE AND PAAF.EFFECTIVE_END_DATE AND PAPF.PERSON_ID = :BLOCK.PER_ID AND PAAF.PRIMARY_FLAG = 'Y' AND PAAF.PERSON_ID = PCF.PERSON_ID (+) AND PAAF.CONTRACT_ID = PCF.CONTRACT_ID (+)

Kind regards

Manu.

Tags: Oracle Development

Similar Questions

  • Nested Select statement help

    I am trying to create a query that returns the last date of order for the customer... the invoiced sales table contains a "calendar_id' I need to select the MAX, and then return the"activity_date"of the calendar table.
    Here's what I have so far...
    ----------
    SELECT
    SALES. NATIVE_REPORTING_CUSTOMER_ID,
    CUST. CLIENT_NAME,
    CUST. SAP_CUSTOMER_NUMBER,
    SALES_AREA. SALES_ORGANIZATION,
    (select
    DW. Calendar.activity_date
    Of
    DW. CALENDAR
    where
    DW. Calendar.calendar_id = Max (SALES. ORDER_CALENDAR_ID))
    as MAX_ORDER_DATE

    Of
    DW. Sale INVOICED_SALES_FACT,
    DW. CUST OF THE CUSTOMER,
    DW. SALES_AREA

    WHERE
    SALES. NATIVE_REPORTING_CUSTOMER_ID = CUST. NATIVE_CUSTOMER_ID
    AND SALES. SALES_AREA_ID = SALES_AREA. SALES_AREA_ID
    AND CUST. CURRENT_FLAG = 'Y '.
    AND SALES_AREA. SALES_ORGANIZATION IN ('ATS1', "ESS1")

    GROUP BY
    SALES. NATIVE_REPORTING_CUSTOMER_ID,
    CUST. CLIENT_NAME,
    CUST. SAP_CUSTOMER_NUMBER,
    SALES_AREA. SALES_ORGANIZATION
    ----------

    But I get the error
    "Group feature is not allowed here."
    which is of course related to the nested select statement I have the return date of the calendar table.

    Pointers?
    THX

    Of course, this should be better:

    SELECT
    xyz.NATIVE_REPORTING_CUSTOMER_ID,
    xyz.CUSTOMER_NAME,
    xyz.SAP_CUSTOMER_NUMBER,
    xyz.SALES_ORGANIZATION,
    (select
    dw.calendar.activity_date
    FROM
    DW.CALENDAR
    where
    dw.calendar.calendar_id=xyz.MAX_SALES_ORDER_CALENDAR_ID) as MAX_ORDER_DATE
    
    FROM (  -- added this
    
    SELECT
    SALES.NATIVE_REPORTING_CUSTOMER_ID,
    CUST.CUSTOMER_NAME,
    CUST.SAP_CUSTOMER_NUMBER,
    SALES_AREA.SALES_ORGANIZATION,
    max(SALES.ORDER_CALENDAR_ID) as MAX_SALES_ORDER_CALENDAR_ID -- changed this
    
    FROM
    DW.INVOICED_SALES_FACT sales,
    DW.CUSTOMER CUST,
    DW.SALES_AREA
    
    WHERE
    SALES.NATIVE_REPORTING_CUSTOMER_ID=CUST.NATIVE_CUSTOMER_ID
    AND SALES.SALES_AREA_ID=SALES_AREA.SALES_AREA_ID
    AND CUST.CURRENT_FLAG='Y'
    AND SALES_AREA.SALES_ORGANIZATION IN ('ATS1','ESS1')
    
    GROUP BY
    SALES.NATIVE_REPORTING_CUSTOMER_ID,
    CUST.CUSTOMER_NAME,
    CUST.SAP_CUSTOMER_NUMBER,
    SALES_AREA.SALES_ORGANIZATION
    
    ) XYZ -- added this
    

    Published by: Toon Koppelaars June 18, 2009 14:23

  • Clause of update with a nested select statement, and a weird error

    Hi all!

    I am trying to execute the following SQL clause:

    setting a day of f_kontakti kon set ikaluokka =
    (
    Select ikal of
    (
    Select kontakt_ik, ikaluokka_gen(1,ai2.pvm,ai.pvm) as ikal
    of f_kontakti k
    Join the a on (k.asiakas_ik = a.asiakas_ik) d_asiakas
    Join d_aika HERE on (a.synt_aika_ik = ai .aika_ik)
    Join d_aika ai2 on (k.aika_ik = ai2.aika_ik)
    where k.kontakt_ik = kon.kontakt_ik
    ) salt
    )

    It works very well on our test database (10.2.0.1.0), but when I try to run it on our production database (10.2.0.4.0), it gives the following error:
    ORA-00904: "KON". "" KONTAKT_IK ": invalid identifier

    The nested select works fine when I run it separately (without where clause of course, because then it does not really anywhere point) on two databases, but for some reason, the full update only fails on the production system. Any ideas on what could cause this?

    Kind regards
    Erik

    You can run it without selecting it nesting.

    Like this

    update f_kontakti kon
    set ikaluokka=
     (
      select ikaluokka_gen(1,ai2.pvm,ai.pvm) as ikal
      from f_kontakti k
      join d_asiakas a on (k.asiakas_ik=a.asiakas_ik)
      join d_aika ai on (a.synt_aika_ik=ai.aika_ik)
      join d_aika ai2 on (k.aika_ik=ai2.aika_ik)
      where k.kontakt_ik=kon.kontakt_ik
    );
    

    or even shorter

    update f_kontakti kon
    set ikaluokka=
     (
      select ikaluokka_gen(1,ai2.pvm,ai.pvm) as ikal
      from d_asiakas a on (kon.asiakas_ik=a.asiakas_ik)
      join d_aika ai on (a.synt_aika_ik=ai.aika_ik)
      join d_aika ai2 on (kon.aika_ik=ai2.aika_ik)
      );
    
  • How to get a select statement to pass a variable as the OUT parameter in PROC

    I have the underside of the nested select statement that returns the name of the missing table (data_table_name).

    How to be an effective way to modify the select statement, so that the returned 'data_table_name' is passed as OUTPUT in a procedure parameter
    select 'Missing Table Name : ' || data_table_name
         from   ( select upper(data_table_name) data_table_name
                  from   TABLE1
                  where  data_table_name in ('ABC',EFG','XYZ')
                MINUS
              ( select upper(fus_data_table_name)
                from   TABLE2
                where  fus_data_table_name in ('EFG',')
              group by
                     upper(fus_data_table_name)
              union
              select upper(fus_data_table_name)
              from   TABLE2
              where  fus_data_table_name = 'LMN'
              group  by
                     upper(fus_data_table_name)
            ));
    Any help is greatly appreciated.

    S
    CREATE OR REPLACE PROCEDURE myproc (tname OUT NOCOPY VARCHAR2) AUTHID CURRENT_USER IS
    BEGIN
      SELECT something
      INTO tname
      FROM whatever;
    EXCEPTION
      WHEN OTHERS THEN
        tname := ;
    END myproc;
    /
    
  • function() nested in the select statement

    Oracle 11g. Try to nest a function within the select statement.  Goal: get the average customer rating for each of the qualified user.

    Select user_name, f_get_avg_cust_rating() "Notation.

    of u, OTHER_TABLES o TAB_USER

    where u.id = o.id and another condition matched;

    How Oracle would deal with the sql.  Is it

    (1) first of all display records based on the where clause, then call the f_get_avg_cust_rating() for each of the selected records OR

    (2) for the analysis in tables, the f_get_avg_cust_rating() will be called for each record met?

    Thank you

    Scott

    Words of Frank, I created two functions with dbms_output and used a function in where clause in select another function. See the bottom of the unit tests. Everyone says, where first clause then select...

    -Where function clause

    SQL > CREATE or REPLACE FUNCTION ret_empno

    2 RETURN NUMBER

    3 AS

    4 BEGIN

    5 DBMS_OUTPUT. Put_line (' where Clause Function');

    6 RETURN 7839;

    7 END;

    8.

    The function is created.

    -Select the function

    SQL > CREATE or REPLACE FUNCTION ret_1

    2 RETURN NUMBER

    3 AS

    4 BEGIN

    5 DBMS_OUTPUT. Put_line ('Select function');

    6 RETURN 1;

    7 END;

    8.

    The function is created.

    SQL > SELECT empno, ename,ret_1

    2 FROM emp

    3. WHERE empno = ret_empno;

    EMPNO, ENAME RET_1

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

    7839 KING 1

    Where the function Clause

    Select the function

  • How can I get the nested case statements to work with listagg?

    I have a statement below that does not work as I want it, here is my code:

    Select

    cases where o.personal_label is not null

    then

    listagg (cases where s.subcodevalue like '% MON %')

    then s.subcodevalue |' '|| o.personal_label

    of other s.subcodevalue

    end,': ')

    the Group (order of s.subcodevalue) as subcodevalue

    on the other

    listagg (s.subcodevalue,': ')

    the Group (order of s.subcodevalue) as subcodevalue

    end

    of mtm_styles_new s, order_mtm o

    where INSTR (o.extras, s.code) > 0

    and o.bodyfitting = s.bodyfitting

    and o.division = s.division

    and s.subcodevalue is not null

    and o.ORDER_MTMID = 'somevalue '.

    It should bring the following

    * MY TEST: RPP

    or the following if the first case is not completed:

    * MONDAY: RPP

    I get an error message saying 'missing keyword', but cannot make out where, can someone please help me here?

    The following works fine as long as it is not a nested case statement, but I need to nest the case statement:

    Select listagg (cases where s.subcodevalue like '% MON %')

    then s.subcodevalue |' '|| o.personal_label

    of other s.subcodevalue

    end,': ')

    the Group (order of s.subcodevalue) as subcodevalue

    of mtm_styles_new s, order_mtm o

    where INSTR (o.extras, s.code) > 0

    and o.bodyfitting = s.bodyfitting

    and o.division = s.division

    and s.subcodevalue is not null

    and o.ORDER_MTMID = 'somevalue ';

    Out alias 'subcodevalue as' the case at the end of the case body.

  • SELECT statement to return a type in Oracle objects

    Hi all, I have created a small system for Uni using oracle objects and types. I have a table person with type of seller under the person table and the type of claimant to the title of the person table. I need the select statement to return data of the person, table, but only the type of applicant data. for example, SELECT * FROM person_tab, WHERE the type is applicant_t. I know it's probably simple, but just can't get the syntax right. The code all series just may not get the right to choose. Thanks for your time.

    create type appointment_t;
            
    create type property_t;
    
    create type telephone_t as object (
        weekdayDaytime varchar2(15),
        weekdayEveningAndWeekend varchar2(15));
    
    create type person_t as object (
        person char(6))
        not final;
    
    create type appointment_list_t as table of ref appointment_t;
    
    create type property_list_t as table of ref property_t;
    
    create type salesperson_t under person_t (
        sSurname varchar2(20),
        sForename varchar2(20),
        dateOfBirth varchar2(12),
        makes appointment_list_t,
        member function appointments_made return number );
    
    create type applicant_t under person_t (
        aSurname varchar2(20),
        aForename varchar2(20),
        dateOfBirth varchar2(12),
        aAddressLine1 varchar2(25),
        aAddressLine2 varchar2(25),
        aTown varchar2(20),
        telephoneNums telephone_t,
        maxPrice number(10),
        desiredArea varchar2(20),
        attends appointment_list_t,
        member function appointments_attended return number );
    
    create or replace type body salesperson_t as
    member function appointments_made return number is
        total number;
    begin
        total := self.makes.count;
        return total;
        end;
    end;
    
    create or replace type body applicant_t as
    member function appointments_attended return number is
        total number;
    begin
        total := self.attends.count;
        return total;
        end;
    end;
    
    create or replace type appointment_t as object (
        appointment char(10),
        appdate date,
        apptime varchar2(15),
        appointmentType varchar2(15),
        levelOfInterest integer(3),
        offerMade number(10),
        is_made_by ref salesperson_t,
        is_attended_by ref applicant_t,
        is_related_to ref property_t);
        
    create or replace type property_t as object (
        property char(10),
        dateOfRegistration date,
        propertyType varchar2(15),
        bedrooms integer(2),
        receptionRooms integer(2),
        bathrooms integer(2),
        garage varchar2(5),
        garden varchar2(6),
        regionArea varchar2(20),
        pAddressLine1 varchar2(20),
        pAddressLine2 varchar2(20),
        pTown varchar2(20),
        askingPrice varchar2(20),
        relatesTo appointment_list_t);
    
    create table person_tab of person_t (
        person primary key );
        
    create table property_tab of property_t (
        primary key(property))
        nested table relatesTo store as relates_to_table;
        
    create table appointment_tab of appointment_t (
        primary key (appointment),
        scope for (is_made_by) is person_tab,
        scope for (is_attended_by) is person_tab,
        scope for (is_related_to) is property_tab);
        
        
    
    insert into person_tab
    values (salesperson_t('s001', 'Fontigue', 'Farquar', '22-feb-1980', appointment_list_t()));
    
    insert into person_tab
    values (salesperson_t('s002', 'Richmond', 'Neil', '30-feb-1983', appointment_list_t()));
    
    insert into person_tab
    values (salesperson_t('s003', 'Devere', 'Jeremy', '03-mar-1977', appointment_list_t()));
    
    insert into person_tab
    values (salesperson_t('s004', 'Schofield', 'Paul', '07-dec-1969', appointment_list_t()));
    
    insert into person_tab
    values (salesperson_t('s005', 'Johnson', 'Richard', '04-jul-1992', appointment_list_t()));
    
    insert into person_tab
    values (salesperson_t('s006', 'Stevens', 'Rupert', '22-may-1989', appointment_list_t()));
    
    
    
    insert into person_tab
    values (applicant_t('ap007', 'Hadfield', 'Linda', '22-nov-1981', '3 Duckdoo Avenue', 'Rosemont', 'Neath Port Talbot',
    telephone_t('01639877103', '07756338175'), '110000', 'Mumbles', appointment_list_t()));
    
    insert into person_tab
    values (applicant_t('ap008', 'Walsh', 'Riley', '18-sep-1974', '12 George Street', 'Taibach', 'Neath Port Talbot',
    '01639890337', '075982228741', '125000', 'Ten Acre Wood', appointment_list_t()));
    
    insert into person_tab
    values (applicant_t('ap009', 'Kennedy', 'Shaun', '11-dec-1972', '101 Granada Close', 'Waun Wen', 'Swansea',
    '01792558447', '07894558123', '150000', 'Central Swansea', appointment_list_t()));
    
    insert into person_tab
    values (applicant_t('ap010', 'Redgrave', 'Steven', '30-jun-1988', '47 Victoria Gardens', 'City Apartments', 'Neath',
    '01639770183', '07774273391', '95000', 'Neath', appointment_list_t()));
    
    insert into person_tab
    values (applicant_t('ap011', 'Hopkins', 'John', '07-feb-1979', '130 Flanders Court', 'Richfield', 'Bridgend',
    '01656889227', '05589337123', '137500', 'Brechfa', appointment_list_t()));
    
    insert into person_tab
    values (applicant_t('ap012', 'Glover', 'Germaine', '14-aug-1983', '32 Regent Crescent', 'Cranforth', 'Cardiff', 
    '01210887336', '07975625195', '170000', 'Cardiff West', appointment_list_t()));
    
    

    
    

    The one I am running made the telephone_t in all households.

    Happy that you have your code working but that was not my point

    It comes to you providing us with the correct instructions to actually run the test case and help you efficiently.

    Regarding your last question, use the function of REGAL to caster level being superior in one of its subtype.

    for example

    SQL> select person
      2       , treat(object_value as applicant_t).aSurname as surname
      3       , treat(object_value as applicant_t).aForename as forename
      4  from person_tab
      5  where object_value is of (applicant_t) ;
    
    PERSON SURNAME              FORENAME
    ------ -------------------- --------------------
    ap007  Hadfield             Linda
    ap008  Walsh                Riley
    ap009  Kennedy              Shaun
    ap010  Redgrave             Steven
    ap011  Hopkins              John
    ap012  Glover               Germaine
    
    6 rows selected.
    
  • Help - nested Case statement

    Hello everyone.  I'm having a hell of a time trying to understand my nested case statement.  It's pretty simple, but I always feel to get this error:

    ORA-00937: not a single group group function
    * 00937. 00000 - 'not a single-group function. "
    Cause:
    Action:

    However, when I try to enter in a "group by" I get this error:

    ORA-00979: not a GROUP BY expression
    * 00979. 00000 - 'not a GROUP BY expression. "
    Cause:
    Action:

    I don't know if there is something wrong with my nested case statement syntax, or miss me something more fundamental. This is my code:
    SELECT AE.EMP_ID,
      CASE
        WHEN EP.PHYSICAL_DATE IS NULL
        THEN
          CASE
            WHEN EC.ORIGINAL_CONTRACT_START < ((SYSDATE) - 365)
            THEN 'NEEDS PHYSICAL'
            WHEN EC.ORIGINAL_CONTRACT_START < ((SYSDATE) - 330)
            THEN 'COMING UP'
            ELSE 'No'
          END
        WHEN MAX(EP.PHYSICAL_DATE) KEEP (DENSE_RANK LAST
        ORDER BY EP.PHYSICAL_DATE) < ((SYSDATE) - 365)
        THEN 'NEEDS PHYSICAL'
        WHEN MAX(EP.PHYSICAL_DATE) KEEP (DENSE_RANK LAST
        ORDER BY EP.PHYSICAL_DATE) < ((SYSDATE) - 330)
        THEN 'COMING UP'
        ELSE 'No'
      END "Needs Physical?"
    FROM AP AE
    LEFT JOIN EMP_PHYSICAL EP
    ON AE.EMP_ID = EP.EMP_ID
    LEFT JOIN POSITION_OFFERED PO
    ON AE.EMP_ID = PO.EMP_ID
    LEFT JOIN EMP_CONTRACT EC
    ON AE.EMP_ID         = EC.EMP_ID
    WHERE PO.ACTUAL_END IS NULL
    AND (EP.PHYSICAL     = 1
    OR EP.PHYSICAL      IS NULL)
    AND :P71_EMP_ID = AE.EMP_ID;
    I appreciate all help. Nice day.

    Aqua

    SELECT AE.EMP_ID,
    CASE
    WHEN EP.PHYSICAL_DATE IS NULL
    THEN
    CASE
    WHEN EC.ORIGINAL_CONTRACT_START < ((SYSDATE) - 365)
    THEN 'NEEDS PHYSICAL'
    WHEN EC.ORIGINAL_CONTRACT_START < ((SYSDATE) - 330)
    THEN 'COMING UP'
    ELSE 'No'
    END
    WHEN MAX(EP.PHYSICAL_DATE) KEEP (DENSE_RANK LAST
    ORDER BY EP.PHYSICAL_DATE) < ((SYSDATE) - 365)
    THEN 'NEEDS PHYSICAL'
    WHEN MAX(EP.PHYSICAL_DATE) KEEP (DENSE_RANK LAST
    ORDER BY EP.PHYSICAL_DATE) < ((SYSDATE) - 330)
    THEN 'COMING UP'
    ELSE 'No'
    END "Needs Physical?"
    FROM AP AE
    LEFT JOIN EMP_PHYSICAL EP
    ON AE.EMP_ID = EP.EMP_ID
    LEFT JOIN POSITION_OFFERED PO
    ON AE.EMP_ID = PO.EMP_ID
    LEFT JOIN EMP_CONTRACT EC
    ON AE.EMP_ID = EC.EMP_ID
    WHERE PO.ACTUAL_END IS NULL
    AND (EP.PHYSICAL = 1
    OR EP.PHYSICAL IS NULL)
    AND :P71_EMP_ID = AE.EMP_ID;
    GROUP BY AE.EMP_ID,EP.PHYSICAL_DATE,EC.ORIGINAL_CONTRACT_START;

    
    

    Hi,

    You need to add Group by clause at the end of the query i have added above.

  • Cross tab in the SELECT statement?

    Hello

    The following SQL statement:
    SELECT
    T.LASTFIRST, C.COURSE_NAME, CC. COURSE_NUMBER, CC. SECTION_NUMBER, CC. EXPRESSION, ST. SEX, COUNT (CC.) STUDENTID) STUDENTCOUNT
    TEACHERS T
    JOIN THE CC
    ON CC. TEACHERID = T.DCID
    JOIN THE COURSE C
    ON C.COURSE_NUMBER = CC. COURSE_NUMBER
    JOIN STUDENTS ST
    ON CC. STUDENTID = ST.ID
    WHERE CC. SCHOOLID = 100 AND TERMID > = 1900
    T.LASTFIRST, C.COURSE_NAME, CC GROUP. COURSE_NUMBER, CC. SECTION_NUMBER, CC. EXPRESSION, ST. BETWEEN THE SEXES
    ORDER OF T.LASTFIRST, CC. COURSE_NUMBER, CC. SECTION_NUMBER, CC. EXPRESSION, ST. BETWEEN THE SEXES

    Returns the following dataset:
    Abram, American history Michael SOC1000 1 a 2 F 7
    Abram, American history Michael SOC1000 1 has 2 M 12

    Is there a way to make the count gender for each sex, introduce yourself as a column in the SELECT statement so that there is only ONE row returned by course number with as FEMALECOUNT and MALECOUNT column headers?

    I tried to use a statement select count nested inside the original SELECT statement but without success.

    Jeff

    You should be able to use a CASE statement for this in collaboration with the County. COUNTY does not indicate that null instances no I have not specified a part to the CASE ELSE (so the default value is NULL).

    COUNT(CASE ST.GENDER WHEN 'F' THEN 1 END) as Female_count,
    COUNT(CASE ST.GENDER WHEN 'M' THEN 1 END) as Male_count, 
    

    Note that you need to remove the Gender of your query column.

  • SQL select statements

    Hey everybody,

    First of all, Yes, I searched through the 8.5 database schema guide.  As I went through the scheme, I've developed some ideas on how to collect the data you want.  However, if someone has already developed or found the SQL statements (which I'm sure that someone already has) it would help by reducing to the minimum of the buggs in my data collection program.

    All these statistics must be grouped by CSQ and selected for a certain time interval ( and ).  That is, levels of 1 hour.  I have no problem to get a list of results and then perform v.f. to achieve the desired final result.  Also, if I need to run several select statements for tables of essentially two join, please include two statements.  Finally, I saw the RtCSQsSummary table, but I need to collect data for the past, not at this time.

    1 total calls presented by the CSQ

    2. total number of calls answered by the CSQ

    3 total number of calls abandoned by the CSQ

    4. percentage of calls abandoned by CSQ (if it is not stored in the database, I think: /)

    5. average abandon time in seconds (if it is not stored in the DB, I think: sum () /)

    6. service level - % calls answered in 90 seonds by a set of skills (I have seen metServiceLevel in the ContactQueueDetail table; however, I need to find how to configure this threshold for application)

    7. average speed of response by CSQ

    8 average conversation by CSQ calls

    9. the aggregates connected full-time resources or agents CSQ

    10. resources/agents of CSQ ready time

    I realize that some of them should be easy to find (as I always am search in the guide of db schema), but I was reading how a new record is created for each step of the call so I could easily see how I could get inaccurate information without properly developed select statements.

    Any help will be greatly appreciated.

    Brendan

    Brendan,

    I read your message very well.

    You have the schema of database with tables and description. each table has its associated tables (connected with primary and foreign keys). I think you should start the tables to determine what you need.

    Cisco uses the stored procedure to prepare the reports. the stored procedure is 'sp_csq_interval' to create the report.

    Activity report of Queue Service contact"

    HTH

    Anas

    Please note all useful posts

  • uniol all in the select statement

    Hi I have a situation where I have to return the value based on the if statement, is it possible to put union all in the select statement

    My use case is

    IN the column State

    If column01 > 0 to condtion 't'

    IF column02 > 0 that the condition of 'Y '.

    Condition IF COLUMN03 > 0 THAN 'w '.

    If COLUMN04 > 0 that the condition of "Z".

    Select 't'

    TableName

    where column01 > 0

    Union of all the

    Select "y".

    TableName

    where column02 > 0

    Union of all the

    Select 'W '.

    TABLENAME

    WHERE COLUMN03 > 0

    I have what it takes to show value as it

    EmpName, condition, empno

    Jerry, T, 0158754585

    TOM, Y, 0054789568

    Am in oracle database 11 g 2

    Yes you can put all THE UNION here

    Select empname, 't' State, empno from tablename where column01 > 0

    Union of all the

    Select empname, 't' State, empno from tablename where column02 > 0

    Union of all the

    Select empname, condition of "W", empno FROM tablename WHERE COLUMN03 > 0

    Union of all the

    Select empname, condition of "Z", empno FROM tablename WHERE COLUMN04 > 0

    and if you are looking for how to remove duplicates because your line might have satisfied all the conditions and my happen 4 times in your result set, you just need to give them an order and filter it.

    For example, you want this

    If column01 > 0 to condtion 't'

    ELSE IF column02 > 0 that the condition of 'Y '.

    Another condition of THAN > 0 IF COLUMN03 'w '.

    otherwise if COLUMN04 > 0 that the condition of "Z".

    Select empname, condition, empno, in

    (

    Select a.*, row_number() over (partition by empno arrested by myorder) rn

    Of

    (

    Select empname, 't' State, empno, 1 myorder tablename where column01 > 0

    Union of all the

    Select empname, 't' State, empno, 2 myorder tablename where column02 > 0

    Union of all the

    Select empname, condition of "W", empno 3 myorder FROM tablename WHERE COLUMN03 > 0

    Union of all the

    Select empname, empno, condition of 'Z', 4 myorder FROM tablename WHERE COLUMN04 > 0

    ) a

    ) where rn = 1

  • Skip and capture the Oracle SQL record dirty in a select statement

    Hello

    I have the Oracle Oracle 11.2.0.4 database when I run a select query.

    Question:

    10 columns have given Date format. When I try to execute this query into a FROG he says, a month not valid. Since the records are billion in nature, I am not able to know which line has this problem.

    Is there a way I can capture the failed row and add it to other tables and continues with the select statement regardless of this error

    OK, you have several TO_DATE functions fed a string that is built on the fly.  At least part of the time, the chain that is built does not match the date format mask used.

    For example:

    TO_DATE (SUBSTR (TO_CHAR (SQ_W_PURCH_CYCLNS_ORA. LAST_SUBMITTED_ON_DTTM_WID), 0, 8). » -'|| SUBSTR (TO_CHAR (SQ_W_PURCH_CYCLNS_ORA. (LAST_SUBMITTED_ON_DTTM_WID), 9, 6), "YYYYMMDD-HH24MISS")

    "SQ_W_PURCH_CYCLNS_ORA. LAST_SUBMITTED_ON_DTTM_WID' does not have a string where characters 5-6 are in the range 01-12.  You'll have to do an analysis on this column.  From its data and how that is managed by to_char.  What ARE the data type of ' SQ_W_PURCH_CYCLNS_ORA. LAST_SUBMITTED_ON_DTTM_WID' and what is a typical value?

    As others have said, this is simply an impossibility for a column of a table to actually have invalid month (or day, or year, or hour or minute or second).  ONLY, you get this error during the conversion of a string to a date with the TO_DATE function.

  • SELECT statement

    Dear all,

    We hope that all are doing well.

    I need your help once again, my requirement is to write a trigger for "select statement" on a particular table, the name and the date of the user who executed.

    your help will be appreciated.

    Thanks in advance.

    OS: RHEL 6.1

    DB: 11.2.0.3

    Trigger is not possible on the SELECT statement, you can audit only by database.

    Or can save your select queries to application level.

  • Need help with the use of GROUP BY in a select statement UNION

    I am writing a query that allows to combine a legacy system that interfaces it is trial balance in the Oracle of R12 GL.  It was only meant to continue for a month or two, but it is likely to continue for 6 months. Please Auditors Auditors, to provide proof that the system is in balance with Oracle GL.  By my verification requirements, I need to make a full reconciliation from the month of conversion (life in the amount of date), then PTD for each month. 

    The legacy account is placed in attribute1 on the lines of the journals. Uses of the old system balancing segments that are also used on the platform in Oracle for this division, i.e., Procure-to-Pay has been cut over Oracle, but not everything yet.  So, I can't count on the GL_BALANCES table for the info, I get from the JE_LINES.

    My problem is not the only request for the month.  But when I try to combine the queries with a Union, to aggregation of each measurement period in its own column, the group is necessary after each selected instruction rather than allowing me to put at the end of the UNION.  (When I put the group by at the end of the UNION, I have the 'not one group' function)

    So I get duplicate for each month of discrete measure accounts. When I duplicate in my Oracle database accounts, I can't count on the VLOOKUP function in excel to exactly match an account of inheritance.  I know there are more sophisticated ways to provide this output, but I'm hoping to get this info in a simple query.

    Thank you in advance for any advice you can provide

    Example of data output (the goal for me is to get the two rows to appear as one based on common points on the LEGACY_ACCOUNT and the ORACLE ACCOUNT

    The LEGACY ACCOUNT ORACLE ACCOUNT JUN_15 JUL_15 AUG_15 SEP_15 OCT_15 NOV_15 DEC_15
    010000001109000003584190-600552-1001-100231-000-0000-0000-000000-242961.040000
    010000001109000003584190-600552-1001-100231-000-0000-0000-00000192588.0200000

    Here is a simplified version of my code that returns both records.  In my research, I had found a number of conversations where it has been shown that the group could be put at the end of the select statement.  However, when I remove the group from the first select statement I get SQL error: ORA-00937: not a function of simple-group

    Select

    l.attribute1 LEGACY_ACCOUNT,

    C.SEGMENT1: '-' | C.SEGMENT2: '-' | C.SEGMENT3: '-' | C.SEGMENT4: '-' | C.SEGMENT5: '-' | C.SEGMENT6: '-' | C.SEGMENT7: '-' | COMBINATION OF C.SEGMENT8,

    JUN_15 TO_NUMBER('0').

    JUL_15, sum (NVL(l.accounted_dr,0.00)-NVL(l.accounted_cr,0.00)),

    TO_NUMBER('0') AUG_15.

    TO_NUMBER('0') SEP_15.

    TO_NUMBER('0') OCT_15.

    TO_NUMBER('0') NOV_15.

    DEC_15 TO_NUMBER('0')

    Of

    b GL.gl_je_batches,

    GL.gl_je_headers h,

    GL.gl_je_lines l,

    GL.gl_code_combinations c,

    GL.gl_je_sources_tl j

    where b.je_batch_id = h.je_batch_id

    and h.je_header_id = l.je_header_id

    and l.code_combination_id = c.code_combination_id

    and h.je_source = j.je_source_name

    and c.segment1 ('190 ', '191', '192', '193', '194', ' 195 ', ' 196',' 197', ' 198 ', ' 199',)

    ('200 ', '203', ' 205', '206 ', '330', '331', '332',' 333 ', ' 334',' 335', ' 336 ', ' 337')

    and j.language = 'en '.

    and h.PERIOD_NAME ("JUL-15'")

    Group

    l.attribute1,

    C.SEGMENT1: '-' | C.SEGMENT2: '-' | C.SEGMENT3: '-' | C.SEGMENT4: '-' | C.SEGMENT5: '-' | C.SEGMENT6: '-' | C.SEGMENT7: '-' | C.SEGMENT8

    UNION

    Select

    l.attribute1 LEGACY_ACCOUNT,

    C.SEGMENT1: '-' | C.SEGMENT2: '-' | C.SEGMENT3: '-' | C.SEGMENT4: '-' | C.SEGMENT5: '-' | C.SEGMENT6: '-' | C.SEGMENT7: '-' | COMBINATION OF C.SEGMENT8,

    JUN_15 TO_NUMBER('0').

    TO_NUMBER('0') JUL_15.

    AUG_15, sum (NVL(l.accounted_dr,0.00)-NVL(l.accounted_cr,0.00)),

    TO_NUMBER('0') SEP_15.

    TO_NUMBER('0') OCT_15.

    TO_NUMBER('0') NOV_15.

    DEC_15 TO_NUMBER('0')

    Of

    b GL.gl_je_batches,

    GL.gl_je_headers h,

    GL.gl_je_lines l,

    GL.gl_code_combinations c,

    GL.gl_je_sources_tl j

    where b.je_batch_id = h.je_batch_id

    and h.je_header_id = l.je_header_id

    and l.code_combination_id = c.code_combination_id

    and h.je_source = j.je_source_name

    and c.segment1 ('190 ', '191', '192', '193', '194', ' 195 ', ' 196',' 197', ' 198 ', ' 199',)

    ('200 ', '203', ' 205', '206 ', '330', '331', '332',' 333 ', ' 334',' 335', ' 336 ', ' 337')

    and j.language = 'en '.

    and h.PERIOD_NAME ("AUG-15'")

    Group

    l.attribute1,

    C.SEGMENT1: '-' | C.SEGMENT2: '-' | C.SEGMENT3: '-' | C.SEGMENT4: '-' | C.SEGMENT5: '-' | C.SEGMENT6: '-' | C.SEGMENT7: '-' | C.SEGMENT8

    order by 1

    Is there a good reason to make this period both as a series of trade unions?  This looks like a classic pivot for me query.  This will make a way through the tables and should get the desired results.

    Select l.attribute1 legacy_account,

    c.Segment1: '-' | c.Segment2: '-' | c.segment3: '-' | c.segment4: '-' |

    c.segment5: '-' | c.segment6: '-' | c.segment7: '-' | combination of c.segment8,

    sum (case when h.period_name = 'JUN-15'

    then nvl(l.accounted_dr,0.00)-nvl(l.accounted_cr,0.00)

    otherwise 0 end) jun_15,.

    sum (case when h.period_name = 'JUL-15'

    then nvl(l.accounted_dr,0.00)-nvl(l.accounted_cr,0.00)

    otherwise 0 end) jul_15,.

    - and similar to DEC - 15

    GL.gl_je_batches b, gl.gl_je_headers h, gl.gl_je_lines l.

    GL.gl_code_combinations c, gl.gl_je_sources_tl j

    where b.je_batch_id = h.je_batch_id

    and h.je_header_id = l.je_header_id

    and l.code_combination_id = c.code_combination_id

    and h.je_source = j.je_source_name

    and c.segment1 ('190', '191', '192', '193', '194', '195',' 196', ' 197',

    '198 ', '199', '200', '203', '205' ', 206',' 330 ', ' 331',

    "332 ', '333', '334', '335',' 336 ', ' 337')

    and j.language = 'en '.

    and h.period_name (' Jun-15', ' 15 JUL', ' AUG-15'... "" ")

    L.attribute1 group,

    c.Segment1: '-' | c.Segment2: '-' | c.segment3: '-' |

    c.segment4: '-' | c.segment5: '-' | c.segment6: '-' |

    c.segment7: '-' | c.segment8

    If you're on the 11G version of the database, you might want to look at the PIVOT keyword that will do the same thing in a more concise expression.

    John

  • How to INSERT a SELECT statement with a GROUP BY clause on a table with an IDENTITY column?

    n an application, I intend to truncate and insertion on a 12 c Oracle database, but have found this problem with a IDENTITY column. Even if the INSERT... SELECT statement works on most SELECT uses I tried, if this statement was also a GROUP BY clause, it does not work, delivering a "ORA-00979: not a GROUP BY expression ' complaint. Some examples of code:

    create table aux ( owner_name varchar2(20), pet varchar2(20) ); 

    insert into aux values ('Scott', 'dog');

    insert into aux values ('Mike', 'dog');

    insert into aux values ('Mike', 'cat');

    insert into aux values ('John', 'turtle'); 


    create table T1 (

    id number generated always as identity,

    owner_name varchar2(20),

    pet_count number );

    select owner_name, count(*) as pet_count from aux group by owner_name; -- works just fine

    insert into T1 (owner_name, pet_count) select owner_name, count(*) as pet_count from aux group by owner_name; -- doesn't work

    The select statement works by itself, but it fails as an INSERT... SELECT statement.

    Appreciate the help!

    Looks like a bug. You must open the SR with Oracle. Meanwhile, you could materialize select:

    SQL > insert into T1 (owner_name, pet_count)
    2 with t as (select / * + materialize * / owner_name, count (*) as pet_count to the owner_name group)
    3. Select owner_name, pet_count t
    4.

    3 lines were created.

    SQL > select * from t1;

    ID OWNER_NAME PET_COUNT
    ---------- -------------------- ----------
    1 John                          1
    Scott 2 1
    3 Mike                          2

    SQL >

    Keep in mind index THAT MATERIALIZE is undocumented.

    SY.

Maybe you are looking for