Analytical and group functions of

Oracle 11g Release 2 Server

SQL, SQLPLUS not

I need to 'break' when a column value changes and insert a line with only a dash.

CREATE TABLE tab
(   id            number
  , part_num      number
  , part_type_id  number
  , part_type_txt varchar2(50)
  , CONSTRAINT tab_pk PRIMARY KEY(part_num,part_type_id)
)
/

insert into tab values(1,10,100,'hose') ;
insert into tab values(1,10,110,'hose clamp') ;
insert into tab values(1,20,200,'plastic value') ;
insert into tab values(1,20,210,'brass value') ;
insert into tab values(1,30,300,'headlamp') ;
insert into tab values(1,30,310,'lamp misc') ;
commit ;

select part_num,part_type_id,part_type_txt, count(part_num) CNT
from   tab
where  id = 1
group by part_num,part_type_id,part_type_txt
order by part_num,part_type_id ;

  PART_NUM PART_TYPE_ID PART_TYPE_TXT       CNT
---------- ------------ ------------------- ----------
        10          100 hose                         1
        10          110 hose clamp                   1
        20          200 plastic value                1
        20          210 brass value                  1
        30          300 headlamp                     1
        30          310 lamp misc                    1

My query:

WITH   data
AS
(
   select   case when nvl( lag( part_num ) over( order by rownum ), ' ' ) != part_num
                 then part_num
            end part_num
         ,  part_type_id, part_type_txt, count(part_num) CNT
   from
            tab
   where    id = 1 
   group by    case when nvl( lag( part_num ) over( order by rownum ), ' ' ) != part_num
                    then part_num
               end 
             , part_type_id
             , part_type_txt
   order by part_num,part_type_id 
)
SELECT rownum, d.part_num,d.part_type_id, d.part_type_txt
FROM   data   d ;

ERROR at line 11:
ORA-30483: window  functions are not allowed here


I guess that analytical functions are not allowed in a group by clause.

Output desired, he had to 'break' on when PART_NUM changes and insertion of a line with a dash (-):

  PART_NUM PART_TYPE_ID PART_TYPE_TXT       CNT
---------- ------------ ------------------- ----------
        10          100 hose                         1
        10          110 hose clamp                   1
        -
        20          200 plastic value                1
        20          210 brass value                  1
        -
        30          300 headlamp                     1
        30          310 lamp misc                    1

Any help appreciated.

Hello

I see: XYZ123 is linked only to a part_type_id, 7777, so you do not want any output to XYZ123.

Similarly, XYZ456 is only linked to a part_type_id, 8888, so you do not want XYZ456.

One thing you can do is to start with the query in response to #4 above.  The results of this query, you can count part_type_ids h: different lots, each part_num is bound to and then only display the part_nums who have more than 1 part_type_id.  For example:

WITH got_aggregates AS

(

SELECT THE CHECK BOX

WHEN you GROUP (part_type_id) = 0

THEN TO_CHAR (part_num)

ELSE '-'

END                               AS txt

part_type_id, part_type_txt

CASE

WHEN you GROUP (part_type_id) = 0

THEN COUNT (part_num)

END                               AS cnt

part_num,

COUNT (DISTINCT part_type_id)

COURSES (PARTITION BY part_num) AS part_type_id_cnt

TAB

ID WHERE = 1

GROUP BY part_num, ROLLUP (part_type_id, part_type_txt))

)

SELECT txt, part_type_id, part_type_txt, cnt

OF got_aggregates

WHERE part_type_id_cnt > 1

ORDER BY part_num, part_type_id

;

Note that the subquery got_aggregates is almost identical to the response query #4.  The only differences are that the subquery is not an ORDERBY clause (ORDER BY is almost always useless to subqueries) and includes two additional columns, which will be needed in the WHERE and ORDER BY the main query clauses.

Tags: Database

Similar Questions

  • Unable to get the database searched with MAX and GROUP BY function

    Hello
    All the

    I have a table as below:
    COLUMN TYPE
    User_id VARCHAR2 (10 byte)
    ID_processus VARCHAR2 (30 bytes)
    END_TIME DATE (STAMP)
    TO_LOC VARCHAR2 (12 bytes)
    TO_LOC_TYPE VARCHAR2 (15 bytes)
    FROM_LOC VARCHAR2 (12 bytes)
    ITEM_ID VARCHAR2 (25 bytes)
    CASE NUMBER (12.4)
    LMS_UDA1 VARCHAR2 (250 bytes)
    AREA VARCHAR2 (2 bytes)

    I only want to get one record with all the columns, have only one clause MAX (END_TIME)
    But the other column value of the difference.
    When I use MAX (END_TIME) and GROUP OF USER_ID, ID_processus, CASE...
    the sql did not a single record,
    It gives the number of records

    Please help me on this

    Concerning

    Saven

    >
    I only want to get one record with all the columns, have only one clause MAX (END_TIME)
    But the other column value of the difference.
    >
    Maybe it's not possible because it depends on your data.

    If the combination of all columns except END_TIME is not unique then there will be multiple records; a record for each unique combination (GROUP BY) of all other columns.

    The only way to ensure that a record is

    SELECT MAX(END_TIME) FROM myTable
    
  • Need help with Group functions

    I'm a total novice with SQL, so please forgive me if the answer to my question seems to be too obvious
    I work with diagrams of the sample (in particular with the employees table):

    DESC employees;
    result

    What I have to do is select all the managers, including the number of subordinates is higher than the average number of subordinates of managers who work in the same Department. What I've done so far is as follows:

    SELECT mgr.employee_id manager_id, Director of mgr.last_name, mgr.department_id, COUNT (emp.employee_id)
    Employees emp employees JOIN Bishop
    ON emp.manager_id = mgr.employee_id
    GROUP OF mgr.employee_id, mgr.last_name, mgr.department_id
    ORDER BY mgr.department_id;
    result

    As you can see, I'm almost done. Now, I need only to calculate the average of the result of the COUNT function for each Department. But I'm totally stuck at this point.
    All advice?

    Hello

    Welcome to the forum!

    user12107811 wrote:
    I'm a total novice with SQL, so please forgive me if the answer to my question seems to be too obvious

    Just the opposite! Looks like a very difficult mission.

    I work with diagrams of the sample (in particular with the employees table):

    DESC employees;
    result

    What I have to do is select all the managers, including the number of subordinates is higher than the average number of subordinates of managers who work in the same Department. What I've done so far is as follows:

    SELECT mgr.employee_id manager_id, Director of mgr.last_name, mgr.department_id, COUNT (emp.employee_id)
    Employees emp employees JOIN Bishop
    ON emp.manager_id = mgr.employee_id
    GROUP OF mgr.employee_id, mgr.last_name, mgr.department_id
    ORDER BY mgr.department_id;
    result

    As you can see, I'm almost done. Now, I need only to calculate the average of the result of the COUNT function for each Department. But I'm totally stuck at this point.
    All advice?

    Yes, you're almost done. You just need to add one more condition. You have to calculate the average value of total_cnt (the COUNT (*) you already do) of a Department and compare that to total_cnt.

    There are several ways to do this, including
    a scalar subquery (in a HAVING clause)
    (b) make a result set with one line per Department, containing the average_cnt and reach than your current result set
    (c) analytical functions. Analytical functions are calculated after the GROUP BY clause is applied and aggregate functions are calculated, it is legitimate to say "AVG (COUNT (*)) MORE (...)").

    If thinking (c) is the simplest. It involves the use of a query of Tahina, but (a) and (b) also require subqueries.

    This sounds like homework, so I'll do it for you.
    Instead, here is a very similar problem with the hr.employees table.
    Let's say that we are interested in total wages given each type of work in each Department.

    SELECT        department_id
    ,        job_id
    ,        SUM (salary)     AS sum_sal
    FROM        hr.employees
    GROUP BY   department_id
    ,             job_id
    ORDER BY   department_id
    ,             job_id
    ;
    

    Results:

    DEPARTMENT_ID JOB_ID        SUM_SAL
    ------------- ---------- ----------
               10 AD_ASST          4400
               20 MK_MAN          13000
               20 MK_REP           6000
               30 PU_CLERK        13900
               30 PU_MAN          11000
               40 HR_REP           6500
               50 SH_CLERK        64300
               50 ST_CLERK        55700
               50 ST_MAN          36400
               60 IT_PROG         28800
               70 PR_REP          10000
               80 SA_MAN          61000
               80 SA_REP         243500
               90 AD_PRES         24000
               90 AD_VP           34000
              100 FI_ACCOUNT      39600
              100 FI_MGR          12000
              110 AC_ACCOUNT       8300
              110 AC_MGR          12000
                  SA_REP           7000
    

    Now suppose we want to find out which of these sum_sals is higher than the average sum_sal of his Department.
    For example, in detriment 110 (near the end OIF the list) there two types of work (AC_ACCOUND and AC_MGR) that have sum_sals of 8300 and 12000. The average of these two numbers is 10150, so we selected AC_MGR (because its sum_sal, 12000, is superior to 10150, and we do not want to include AC_ACCOUNT, because its sum_sal, 8300, is less than or equal to the average of the Department.
    In departments where there is only one job type (for example, Department 70, or null "Department" at the end of the list above) the only sum_sal will be the average; and because the sum_sal is not greater than the average, we want to exclude this line.

    Let's start with the calculation of the avg_sum_sal using the analytical function AVG:

    SELECT        department_id
    ,        job_id
    ,        SUM (salary)                              AS sum_sal
    ,        AVG (SUM (salary)) OVER (PARTITION BY department_id)     AS avg_sum_sal
    FROM        hr.employees
    GROUP BY   department_id
    ,             job_id
    ORDER BY   department_id
    ,             job_id
    ;
    

    Output:

    DEPARTMENT_ID JOB_ID        SUM_SAL AVG_SUM_SAL
    ------------- ---------- ---------- -----------
               10 AD_ASST          4400        4400
               20 MK_MAN          13000        9500
               20 MK_REP           6000        9500
               30 PU_CLERK        13900       12450
               30 PU_MAN          11000       12450
               40 HR_REP           6500        6500
               50 SH_CLERK        64300  52133.3333
               50 ST_CLERK        55700  52133.3333
               50 ST_MAN          36400  52133.3333
               60 IT_PROG         28800       28800
               70 PR_REP          10000       10000
               80 SA_MAN          61000      152250
               80 SA_REP         243500      152250
               90 AD_PRES         24000       29000
               90 AD_VP           34000       29000
              100 FI_ACCOUNT      39600       25800
              100 FI_MGR          12000       25800
              110 AC_ACCOUNT       8300       10150
              110 AC_MGR          12000       10150
                  SA_REP           7000        7000
    

    Now all we have to do is to compare the sum_sal and avg_sum_sal columns.
    Given that the analytic functions are calculated after the WHERE clause is applied, we cannot use avg_sum_sal in the WHERE clause of the query, even where it has been calculated. But we can do that in a subquery; Then, we can use avg_sum_sal in any way that we love in the Super-requete:

    WITH     got_avg_sum_sal       AS
    (
         SELECT        department_id
         ,        job_id
         ,        SUM (salary)                              AS sum_sal
         ,        AVG (SUM (salary)) OVER (PARTITION BY department_id)     AS avg_sum_sal
         FROM        hr.employees
         GROUP BY   department_id
         ,             job_id
    )
    SELECT        department_id
    ,        job_id
    ,        sum_sal
    FROM        got_avg_sum_sal
    WHERE        sum_sal     > avg_sum_sal
    ORDER BY   department_id
    ,             job_id
    ;
    

    Results:

    DEPARTMENT_ID JOB_ID        SUM_SAL
    ------------- ---------- ----------
               20 MK_MAN          13000
               30 PU_CLERK        13900
               50 SH_CLERK        64300
               50 ST_CLERK        55700
               80 SA_REP         243500
               90 AD_VP           34000
              100 FI_ACCOUNT      39600
              110 AC_MGR          12000
    
  • command and group numbers

    Hello

    I have a number of lines where each shows a quantity (in a single column) with a length of wood (in another column), say...

    3 4500

    2 3000

    1 6000

    9 3000

    1 4500

    is there a formula where I can create two additional columns with the sum total of all the required lengths? so, something like this...

    11 3000

    4 4500

    1 6000

    the order of length?

    also, it will not be fixed lengths, so ideally my formula will order and group some lengths come in the columns.

    hope that makes since, cheers, ric

    I think I could to make it simpler, in my second list "lengths", list all possible, according to the digital agenda, such as 3000, 3200, 3600, etc. 3800.

    in this case, I'm sure that there is a simple way to add the amount of items (in the first column of the first series) each time the length is displayed in the second column (in the first game)...? !

    I don't know the best function to use... :-/

  • No group functionality

    Since around seven 30 - Oct 1st or so I was unable to use all group functions in any group. 'Old' and those that I just created. I can't send or receive calls or messages in any group. I tried these steps below, and none of them worked. Help?

    (1) sign out and back in

    (2) change of profile information

    (3) update the customer on the later (7.11.0.102)

    (4) to uninstall and reinstall Skype

    (5) clean uninstall and reinstall of Skype

    (6) signature mobile to see if that will fix anything on the end of my PC

    Mobile works very well, however my PC version does not. It worked very well in advance and then just suddenly stopped working for groups. Update the client did nothing. However, I can / message of appeal to people individually. I don't understand. I thought it was the linked server, but my friends have not had any problems...

    Skype is based on some Windows Services work properly, or something?

    I'm under 10 Home Windows (64-bit).

    Welp, after scouring the net I found the problem. It turns out that my situation was the same as this post here.

    http://community.Skype.com/T5/Windows-desktop-client/re-Skype-connection-problems-MSNP-connection-of...

  • Win 7 Pro - all users in local users and groups

    Hello I have a new install of Windows 7 Pro with two users; Administrator (built in) and my personal user (CCzahor). I can connect to windows very well with both users.  When I right click my computer and manage them, there is no user appearing in "users and groups / users.  However, if I go to groups, double-click 'Administrators', I see Director listed, and I see CCzahor under "users".  In addition, when I run lusrmgr.msc, I see the same thing as described above, but when I run netplwiz.msc, I see the admin and CCzahor displayed in the list.

    It is not functionally a problem, but rather a nuisance than anything else.  Any ideas?

    Hello

    Please provide a detailed description of the issue.

    I understand the inconvenience you encountered. I will certainly help you with information.

    Note: Users and groups is located in computer management. A collection of administrative tools that you can use to manage a local computer or a remote computer. Please see the link below.

    Local users and groups overview

    https://TechNet.Microsoft.com/en-us/library/cc770756.aspx?f=255&MSPPError=-2147217396

    Important: Under local users and groups, you must click users to see users and groups. And if the two accounts you have in the system have administrator permissions, it's going to be reflective under the administrator group.

    I hope this information is useful.

    Please provide us with the information above to help you best.

    Thank you.

  • Help with error - 934 group function is not allowed here

    Hey there will, I'm having problems with a request and just does not know how to do it without error.

    I'm trying to get all the employee emerging infectious diseases that have less than 2 number max of DID (dependants) in the table.

    It's my current query

    SELECT Employee.LName. ' ' || Employee.Fname as Full_Name, Employee.EID

    The left outer JOIN employee depends on Employee.EID = Dependent.EID

    Having Count (DID)--2 > ((select Max (N) as From (SELECT Employee.EID, Count (DID) As N FROM Employee Inner Join Dependent On Employee.EID = Dependent.EID group by Employee.EID, Count (DID))) N)

    Order of Employee.Lname, Employee.Fname

    Which gives me an error on column 4, no matter what I do. If I remove the Count (DID) in the group by clause (which I tried it earlier), it gives me a is not an error of the function of single group...

    The most frustrating thing is that

    Select Max (N) as From (SELECT Employee.EID, Count (DID) As N FROM Employee Inner Join Dependent On Employee.EID = Dependent.EID group by Employee.EID) N

    Works perfectly, but because it's a mission, I have to do in one step (no substeps/views)

    Any help?

    Thank you very much

    Hello

    ac981e5d-D10A-4520-BF42-23a894d04fb7 wrote:

    Ok. I'm taking your code in a view... I get this.

    and there is an orange underscore and a text of the error that says

    Select incoherent list in group by... change the group by clause of e.fname, e.lname, e.eid, count, max

    Which isn't what either the Oracle database would do.  Everything about orange (or any other color) sounds like it is caused by a front-end that could be interacting with Oracle.  In addition, the Oracle error messages always come with a 3-letter-5 code, as ORA-00933.

    under the selection internal (first medium)

    You have deleted the WITH clause.  The parser can recognize the error when it has reached the first left parenthesis.

    Create view AS A10T2

    (

    SELECT e.lname. ' ' || e.fname AS full_name

    e.eid

    (D.) AS this_group_count

    MAX (COUNT (d.)) ON (AS highest_group_count)

    E employee

    LEFT OUTER JOIN dependent d ON e.eid = d.eid

    GROUP BY e.lname, e.fname, e.eid

    )

    SELECT full_name

    eid

    Of aggregate_results

    WHERE this_group_count > = highest_group_count - 2

    ORDER BY full_name

    You need the WITH to define this clause means "AGGREGATE_RESULTS":

    Create view AS A10T2

    WITH aggregate_results AS

    (

    SELECT e.lname. ' ' || e.fname AS full_name

    ...

    Why do you have an ORDER BY clause in a view?   (It is probably not cause of your errors, just make the inefficient view)

    Command line error: column 5: 23

    Error report-

    SQL error: ORA-00933: SQL not correctly completed command

    00933 00000 - "not correctly completed SQL command.

    * Cause:

    * Action:

    This is another indication that some front is getting involved.  Looks like your front-end reports the exact Oracle error message, "0RA-00933" and then builing it's own error code, "00933. 00000 ", on this basis.  ORA-00933 is a reasonable mistake to wait if you omit the line ' WITH the aggregated results AS.  Once again, until I can actually run your code, I can't test it, and I can't run your code until you post CREATE TABLE and INSERT statements for some examples of data, or change the problem to use commonly available tables, such as those in the scott schema.

    and when I try my code

    CREATE VIEW A10T2 AS

    SELECT Employee.LName. ' ' || Employee.Fname as Full_Name, Employee.EID

    The left outer JOIN employee depends on Employee.EID = Dependent.EID

    Seen (Count (DID)) + 2 > (select Max (N) From (SELECT Employee.EID, Count (DID) As "N" FROM Employee Inner Join Dependent On Employee.EID = Dependent.EID group by Employee.EID))

    Order of Employee.Lname, Employee.Fname

    I get

    Command line error: column 2: 8

    Error report-

    SQL error: ORA-00937: not a function of simple-group

    00937 00000 - 'not a single-group function.

    * Cause:

    * Action:

    Then the orange underscore even under my inner ("select employee. EID, Count (DID) as "N" ") says to change the Group of Employee.eid, Count (DID)

    I just don't understand why he tells me to group them by Count (DID)?

    Isn't that what you did in your original post, and I have explained in answer #2?  If you continue to repeat the same mistake, you can expect continue to get the same error.  Given that you have a code, you know causes an error, do you think really that what makes a vision will cause the error to disappear?

    The inner query works fine on its own...

    Right; It's the outer query where you are missing the GROUP BY clause.

  • not a single group function

    Hello


    I have this request with me
    select  
    mst.ENTRY_DATE    ordered_date , mst.FIELD, 
    V.ADDRESS1        Address   , 
    OPN_JOB_DESC      job_number,
    ra.CUSTOMER_NAME    customer_NAME, 
    DECODE ( GROSS_ITEM_REF , NULL , SUBSTR (PRODUCT_ATTR_VAL_DISP , INSTR( PRODUCT_ATTR_VAL_DISP, '.', -1, 1) + 1  ) , GROSS_ITEM_REF )      item_number, 
    dECODE (GROSS_ITEM_NAME , NULL,itm.attribute2,GROSS_ITEM_NAME  )        item_description, 
    subdtlest.ITEM_UOM                unit_of_measurement, 
    SUM ( subdtlest.QTY_ISSUE  )            Quantity_Issue,
    sum(nvl (subdtlest.CALC_CEMENT_SK ,subdtlest.CALC_AMOUNT ) )    quantity ,
    mst.DN_DESCRIPTION   Description
    --decode(MST.DESCRIPTION ,NULL ,mst.DN_DESCRIPTION,MST.DESCRIPTION) Description
     from 
       XXNP_OPN_JOBLOG_001          mst , 
       XXNP_OPN_JOBLOG_STAGE_002   dtl , 
       XXNP_OPN_JOBLOG_SLURRY_003  subdtl ,
       XXNP_OPN_JOBLOG_EST_002     subdtlest,
       qp_list_lines_v            line  ,
       QP_LIST_HEADERS_TL          head  ,
       QP_LIST_HEADERS_B           curr,   
       ra_customers ra ,
       AR_ADDRESSES_V v ,
       MTL_SYSTEM_ITEMS itm  
       where   
    dtl.OPN_JOBLOG_001_ID                        = mst.OPN_JOBLOG_001_ID         AND 
    subdtl.OPN_JOBLOG_001_ID                = dtl.OPN_JOBLOG_001_ID          AND
    subdtl.OPN_JOBLOG_006_ID                  = dtl.OPN_JOBLOG_006_ID         and  
    subdtlest.OPN_JOBLOG_001_ID           = subdtl.OPN_JOBLOG_001_ID       AND
    subdtlest.OPN_JOBLOG_006_ID         = subdtl.OPN_JOBLOG_006_ID      AND
    subdtlest.OPN_JOBLOG_007_ID         = subdtl.OPN_JOBLOG_007_ID      AND
    line.LIST_HEADER_ID          =       head.LIST_HEADER_ID                          and  
    curr.LIST_HEADER_ID              =   head.LIST_HEADER_ID                        and  
    substr ( PRODUCT_ATTR_VAL_DISP , 1, instr ( PRODUCT_ATTR_VAL_DISP ,'.' )-1 )  = subdtlest.ITEM_NUMBER
    and   itm.SEGMENT3 = substr ( PRODUCT_ATTR_VAL_DISP , INSTR(PRODUCT_ATTR_VAL_DISP, '.', -1, 1) + 1  ) 
    and   mst.CONTRACT                       =  head.name   
    and   RA.CUSTOMER_ID = v.CUSTOMER_ID
    and   ra.customer_id = mst.customer_id
    and   V.ADDRESS1 =  mst.CONTRACT      
    and mst.OPN_JOB_DESC='K/D/UP24/UN006/KOP/PL/0112/1'
    and itm.ORGANIZATION_ID  =103
    and itm.INVENTORY_ITEM_STATUS_CODE = 'Active'
    group by 
    mst.ENTRY_DATE ,  
    V.ADDRESS1     , 
    OPN_JOB_DESC   ,mst.FIELD,
    ra.CUSTOMER_NAME , 
    substr ( PRODUCT_ATTR_VAL_DISP , INSTR(PRODUCT_ATTR_VAL_DISP, '.', -1, 1) + 1  ), 
    itm.ATTRIBUTE2        , 
    subdtlest.ITEM_UOM ,
    mst.DN_DESCRIPTION  ,GROSS_ITEM_REF ,GROSS_ITEM_NAME
    order by  substr ( PRODUCT_ATTR_VAL_DISP , INSTR(PRODUCT_ATTR_VAL_DISP, '.', -1, 1) + 1  )   Asc
    
    i require  a field called balance which is sum of Quantity_issue and Quantity fields
    i tried this
    
    select  
    mst.ENTRY_DATE    ordered_date , mst.FIELD, 
    V.ADDRESS1        Address   , 
    OPN_JOB_DESC      job_number,
    ra.CUSTOMER_NAME    customer_NAME, 
    DECODE ( GROSS_ITEM_REF , NULL , SUBSTR (PRODUCT_ATTR_VAL_DISP , INSTR( PRODUCT_ATTR_VAL_DISP, '.', -1, 1) + 1  ) , GROSS_ITEM_REF )      item_number, 
    dECODE (GROSS_ITEM_NAME , NULL,itm.attribute2,GROSS_ITEM_NAME  )        item_description, 
    subdtlest.ITEM_UOM                unit_of_measurement, 
    SUM ( subdtlest.QTY_ISSUE  )            Quantity_Issue,
    sum(nvl (subdtlest.CALC_CEMENT_SK ,subdtlest.CALC_AMOUNT ) )    quantity ,
    sum(sum(nvl (subdtlest.CALC_CEMENT_SK ,subdtlest.CALC_AMOUNT ) ) + SUM ( subdtlest.QTY_ISSUE  )  )balance,
    mst.DN_DESCRIPTION   Description
    --decode(MST.DESCRIPTION ,NULL ,mst.DN_DESCRIPTION,MST.DESCRIPTION) Description
     from 
       XXNP_OPN_JOBLOG_001          mst , 
       XXNP_OPN_JOBLOG_STAGE_002   dtl , 
       XXNP_OPN_JOBLOG_SLURRY_003  subdtl ,
       XXNP_OPN_JOBLOG_EST_002     subdtlest,
       qp_list_lines_v            line  ,
       QP_LIST_HEADERS_TL          head  ,
       QP_LIST_HEADERS_B           curr,   
       ra_customers ra ,
       AR_ADDRESSES_V v ,
       MTL_SYSTEM_ITEMS itm  
       where   
    dtl.OPN_JOBLOG_001_ID                        = mst.OPN_JOBLOG_001_ID         AND 
    subdtl.OPN_JOBLOG_001_ID                = dtl.OPN_JOBLOG_001_ID          AND
    subdtl.OPN_JOBLOG_006_ID                  = dtl.OPN_JOBLOG_006_ID         and  
    subdtlest.OPN_JOBLOG_001_ID           = subdtl.OPN_JOBLOG_001_ID       AND
    subdtlest.OPN_JOBLOG_006_ID         = subdtl.OPN_JOBLOG_006_ID      AND
    subdtlest.OPN_JOBLOG_007_ID         = subdtl.OPN_JOBLOG_007_ID      AND
    line.LIST_HEADER_ID          =       head.LIST_HEADER_ID                          and  
    curr.LIST_HEADER_ID              =   head.LIST_HEADER_ID                        and  
    substr ( PRODUCT_ATTR_VAL_DISP , 1, instr ( PRODUCT_ATTR_VAL_DISP ,'.' )-1 )  = subdtlest.ITEM_NUMBER
    and   itm.SEGMENT3 = substr ( PRODUCT_ATTR_VAL_DISP , INSTR(PRODUCT_ATTR_VAL_DISP, '.', -1, 1) + 1  ) 
    and   mst.CONTRACT                       =  head.name   
    and   RA.CUSTOMER_ID = v.CUSTOMER_ID
    and   ra.customer_id = mst.customer_id
    and   V.ADDRESS1 =  mst.CONTRACT      
    --and   OPN_JOB_DESC = :P_JOB_NUMBER
    and itm.ORGANIZATION_ID  =103
    and itm.INVENTORY_ITEM_STATUS_CODE = 'Active'
    and mst.OPN_JOB_DESC='K/D/UP24/UN006/KOP/PL/0112/1'
    group by 
    mst.ENTRY_DATE ,  
    V.ADDRESS1     , 
    OPN_JOB_DESC   ,mst.FIELD,
    ra.CUSTOMER_NAME , 
    substr ( PRODUCT_ATTR_VAL_DISP , INSTR(PRODUCT_ATTR_VAL_DISP, '.', -1, 1) + 1  ), 
    itm.ATTRIBUTE2        , 
    subdtlest.ITEM_UOM ,
    subdtlest.CALC_CEMENT_SK ,subdtlest.CALC_AMOUNT, subdtlest.QTY_ISSUE ,
    mst.DN_DESCRIPTION  ,GROSS_ITEM_REF ,GROSS_ITEM_NAME
    order by  substr ( PRODUCT_ATTR_VAL_DISP , INSTR(PRODUCT_ATTR_VAL_DISP, '.', -1, 1) + 1  )   Asc
    
    but i get the cursor pointing to mst.entry_date and the message "not a single group function"
    
    kindly guide me
    thanking in advance
  • Group functions

    Hello

    Is it possible to aggregate group functions based on a field in responses, my query is below:

    SELECT Absence_Days,
    Absence_Reason,
    Absence_Type,
    Employee_name,
    End_date,
    First name,
    Last_name,
    Person_Id,
    Start_date,
    DEPARTMENT,
    DIVISION,
    INTERNAL_LOCATION,
    CASE
    WHERE LAST_NAME = 'Gordon '.
    THEN COUNT (person_id) * COUNT (Person_Id) * SUM (Absence_Days)
    0 OTHERWISE
    END
    FROM EMP
    WHERE LAST_NAME = 'Gordon '.
    GROUP OF ABSENCE_DAYS, ABSENCE_REASON, ABSENCE_TYPE, EMPLOYEE_NAME, END_DATE, FIRST_NAME, LAST_NAME, PERSON_ID, START_DATE, DEPARTMENT, DIVISION, INTERNAL_LOCATION

    Count (person_id) * COUNT (Person_Id) * SUM (Absence_Days) returns a value by each line and aggregate in the column of fx. I want to this group by person_id, is this possible?

    Thank you

    Hello

    Try this in Fx

    SUM (Absence_Days by person_id)

    Thank you
    Saichand.v

  • By the way where and group by clause Cursor

    I'm working on a procedure that generates a where clause clause and needs of a group by clause to return the correct results. I'm moving the two where and group variables in the cursor.

    The variables are is filled correctly, but when the cursor is created, variables are not in the cursor.

    Here's the code I'm working with. It is part of a package, but does no appeal to other parts of the package.

    PROCEDURE createFollowUpTask_Exposure (psUppgkedjetyp IN tis.tial.uppgkedjetyp%TYPE NULL by default,
    psAlarmtyp IN tis.tial.alarmtyp%TYPE by default NULL,
    psSubtyp IN tis.tial.subtyp%TYPE by default NULL,
    pnDays in NUMBER NULL by default,
    psKampkod IN tis.tiin.kampkod%TYPE by default NULL,
    psKatnr IN tis.tiin.katnr%TYPE by default NULL,
    psUtgava IN tis.tiin.utgava%TYPE by default NULL,
    psKatslag IN tis.tikg.katslag%TYPE by default NULL,
    psProdsyst IN tis.tikg.prodsyst%TYPE by default NULL,
    psUppgtyp IN tis.tiin.uppgtyp%TYPE by default NULL,
    psProdkod IN tis.tiin.prodkod%TYPE by default NULL,
    psStatus IN tis.tiin.status%TYPE by default NULL
    ) AS
    --
    cTIAL tis.tial%ROWTYPE;
    vLopnr tis.tial.lopnr%TYPE;
    vSqlWhere VARCHAR2 (4000);
    vGroupBy VARCHAR2 (1000): = "tiin.kampkod, tiin.abnr, tiko.fordsalj;
    cSelectCursor SYS_REFCURSOR;
    vSqlSelect VARCHAR2 (4000);
    psDays VARCHAR2 (50);
    cRec T_TIAL_REC;
    nCount number: = 0;

    --
    CURSOR cSqlSelect (SqlWhere IN VARCHAR2, GroupBy IN VARCHAR2) IS
    SELECT tiin.kampkod, tiin.abnr, tiko.fordsalj, MAX (tici.regdat) ALARMDATE
    OF tis.tiin
    JOIN tis.tiko ON tiin.kampkod = tiko.kampkod AND tiin.abnr = tiko.abnr
    JOIN core.tici ON tiin.kampkod = tici.kampkod AND tiin.abnr = tici.abnr AND tici.inplnr = tiin.inplnr
    WHERE 1 = 1 | SqlWhere
    GroupBy GROUP;
    --
    BEGIN
    -If these parameters are null, trigger the error
    IF psUppgkedjetyp IS NULL and psSubtyp IS NULL THEN
    raise_application_error (-20001,
    "String from the event or events must be assigned");
    END IF;
    -Fill the TIAL values
    IF psUppgkedjetyp IS NOT NULL THEN
    cTIAL.Uppgkedjetyp: = psUppgkedjetyp;
    END IF;
    --
    IF psAlarmtyp IS NOT NULL THEN
    cTIAL.Alarmtyp: = psAlarmtyp;
    END IF;
    --
    cTIAL.Handklass: = 't';
    cTIAL.Blobid: = 0;
    --
    IF pnDays IS NOT NULL THEN
    psDays: = '+' | pnDays;
    END IF;
    IF psSubtyp IS NOT NULL THEN
    cTIAL.Subtyp: = psSubtyp;
    END IF;
    -Create Where clause for cursor
    vSqlWhere: = ";
    IF psKampkod IS NOT NULL THEN
    vSqlWhere: = vSqlWhere | "AND tiin.kampkod ="' | psKampkod | " ' ;
    END IF;
    --
    IF psKatnr IS NOT NULL THEN
    vSqlWhere: = vSqlWhere | "AND tiin.katnr ="' | psKatnr | " ' ;
    END IF;
    --
    IF psUtgava IS NOT NULL THEN
    vSqlWhere: = vSqlWhere | "AND tiin.utgava ="' | psUtgava | " ' ;
    END IF;
    --
    IF psKatslag IS NOT NULL THEN
    vSqlWhere: = vSqlWhere | "AND tikg.katslag ="' | psKatslag | " ' ;
    END IF;
    --
    IF psProdsyst IS NOT NULL THEN
    vSqlWhere: = vSqlWhere | "AND tikg.prodsyst ="' | psProdsyst | " ' ;
    END IF;
    --
    IF psUppgtyp IS NOT NULL THEN
    vSqlWhere: = vSqlWhere | "AND tiin.uppgtyp ="' | psUppgtyp | " ' ;
    END IF;
    --
    IF psProdkod IS NOT NULL THEN
    vSqlWhere: = vSqlWhere | "AND tiin.prodkod ="' | psProdkod | " ' ;
    END IF;
    --
    IF psStatus IS NOT NULL THEN
    vSqlWhere: = vSqlWhere | "AND tiin.status ="' | psStatus | " ' ;
    END IF;
    -Browse all records in input parameters of the meeting and set values required TIAL.
    I'm IN cSqlSelect (vSqlWhere, vGroupBy)
    --
    LOOP
    -EXTRACT cSelectCursor INTO cRec;
    cTIAL.Kampkod: = ";
    cTIAL.Abnr: = ";
    cTIAL.Sign: = ";
    cTIAL.Alarmdate: = ";
    cTIAL.Kampkod: = i.Kampkod;
    cTIAL.Abnr: = i.Abnr;
    cTIAL.Sign: = i.fordsalj;
    cTIAL.Alarmdate: = i.alarmdate;
    --
    nCount: = nCount + 1;
    --
    IF vLopnr = - 1 THEN
    raise_application_error (-20002,
    "Error creating task for: ' | '. cTIAL.Kampkod |' '|| cTIAL.Abnr |' Sales representative: ' | cTIAL.Alarmdate);
    END IF;
    END LOOP;
    DBMS_OUTPUT. Put_line (' I created ' | nCount |) "documents.");



    END createFollowUpTask_Exposure;

    Thanks in advance for any help.

    Hello

    Welcome to the forum!

    Try this (untested) example:

    PROCEDURE createFollowUpTask_Exposure(psUppgkedjetyp IN tis.tial.uppgkedjetyp%TYPE DEFAULT NULL,
                                          psAlarmtyp     IN tis.tial.alarmtyp%TYPE DEFAULT NULL,
                                          psSubtyp       IN tis.tial.subtyp%TYPE DEFAULT NULL,
                                          pnDays         IN NUMBER DEFAULT NULL,
                                          psKampkod      IN tis.tiin.kampkod%TYPE DEFAULT NULL,
                                          psKatnr        IN tis.tiin.katnr%TYPE DEFAULT NULL,
                                          psUtgava       IN tis.tiin.utgava%TYPE DEFAULT NULL,
                                          psKatslag      IN tis.tikg.katslag%TYPE DEFAULT NULL,
                                          psProdsyst     IN tis.tikg.prodsyst%TYPE DEFAULT NULL,
                                          psUppgtyp      IN tis.tiin.uppgtyp%TYPE DEFAULT NULL,
                                          psProdkod      IN tis.tiin.prodkod%TYPE DEFAULT NULL,
                                          psStatus       IN tis.tiin.status%TYPE DEFAULT NULL) AS
       --
       cTIAL         tis.tial%ROWTYPE;
       vLopnr        tis.tial.lopnr%TYPE;
       vSqlWhere     VARCHAR2(4000);
       vGroupBy      VARCHAR2(1000) := ' tiin.kampkod, tiin.abnr, tiko.fordsalj';
       cSelectCursor SYS_REFCURSOR;
       vSqlSelect    VARCHAR2(4000);
       psDays        VARCHAR2(50);
       cRec          T_TIAL_REC;
       nCount        NUMBER := 0;
    
       FUNCTION fnc_cSqlSelect(SqlWhere IN VARCHAR2,
                               GroupBy  IN VARCHAR2) RETURN VARCHAR2 IS
       BEGIN
          RETURN 'SELECT tiin.kampkod,
                 tiin.abnr,
                 tiko.fordsalj,
                 MAX(tici.regdat) ALARMDATE
            FROM tis.tiin
            JOIN tis.tiko ON tiin.kampkod = tiko.kampkod
                         AND tiin.abnr = tiko.abnr
            JOIN core.tici ON tiin.kampkod = tici.kampkod
                          AND tiin.abnr = tici.abnr
                          AND tici.inplnr = tiin.inplnr
           WHERE 1 = 1 ' || SqlWhere || ' GROUP BY ' || GroupBy;
       END fnc_cSqlSelect;
    
    BEGIN
       -- If these parameters are null, raise error
       IF psUppgkedjetyp IS NULL AND psSubtyp IS NULL THEN
          raise_application_error(-20001,
                                  'Either Event Chain or Starting Event must be assigned');
       END IF;
       -- Populate TIAL values
       IF psUppgkedjetyp IS NOT NULL THEN
          cTIAL.Uppgkedjetyp := psUppgkedjetyp;
       END IF;
       --
       IF psAlarmtyp IS NOT NULL THEN
          cTIAL.Alarmtyp := psAlarmtyp;
       END IF;
       --
       cTIAL.Handklass := 'T';
       cTIAL.Blobid    := 0;
       --
       IF pnDays IS NOT NULL THEN
          psDays := '+ ' || pnDays;
       END IF;
       IF psSubtyp IS NOT NULL THEN
          cTIAL.Subtyp := psSubtyp;
       END IF;
       -- Create Where clause for cursor
       vSqlWhere := '';
       IF psKampkod IS NOT NULL THEN
          vSqlWhere := vSqlWhere || ' AND tiin.kampkod = ''' || psKampkod || '''';
       END IF;
       --
       IF psKatnr IS NOT NULL THEN
          vSqlWhere := vSqlWhere || ' AND tiin.katnr = ''' || psKatnr || '''';
       END IF;
       --
       IF psUtgava IS NOT NULL THEN
          vSqlWhere := vSqlWhere || ' AND tiin.utgava = ''' || psUtgava || '''';
       END IF;
       --
       IF psKatslag IS NOT NULL THEN
          vSqlWhere := vSqlWhere || ' AND tikg.katslag = ''' || psKatslag || '''';
       END IF;
       --
       IF psProdsyst IS NOT NULL THEN
          vSqlWhere := vSqlWhere || ' AND tikg.prodsyst = ''' || psProdsyst || '''';
       END IF;
       --
       IF psUppgtyp IS NOT NULL THEN
          vSqlWhere := vSqlWhere || ' AND tiin.uppgtyp = ''' || psUppgtyp || '''';
       END IF;
       --
       IF psProdkod IS NOT NULL THEN
          vSqlWhere := vSqlWhere || ' AND tiin.prodkod = ''' || psProdkod || '''';
       END IF;
       --
       IF psStatus IS NOT NULL THEN
          vSqlWhere := vSqlWhere || ' AND tiin.status = ''' || psStatus || '''';
       END IF;ç
       -- Loop through all records meeting input parameters and set required TIAL values.
       OPEN cSelectCursor FOR fnc_cSqlSelect(vSqlWhere,
                                             vGroupBy);
    
       LOOP
          FETCH cSelectCursor
             INTO v; -- You must define a variable 'v' to hold the data of cursor
          EXIT WHEN cSelectCursor%NOTFOUND;
    
          --FETCH cSelectCursor INTO cRec;
          cTIAL.Kampkod   := '';
          cTIAL.Abnr      := '';
          cTIAL.Sign      := '';
          cTIAL.Alarmdate := '';
          cTIAL.Kampkod   := i.Kampkod;
          cTIAL.Abnr      := i.Abnr;
          cTIAL.Sign      := i.fordsalj;
          cTIAL.Alarmdate := i.alarmdate;
          --
          nCount := nCount + 1;
          --
          IF vLopnr = -1 THEN
             raise_application_error(-20002,
                                     'Error Creating task for: ' || cTIAL.Kampkod || ' ' ||
                                     cTIAL.Abnr || ' Sales Rep: ' || cTIAL.Alarmdate);
          END IF;
       END LOOP;
    
       CLOSE cSelectCursor;
    
       DBMS_OUTPUT.PUT_LINE('I created ' || nCount || ' records.');
    
    END createFollowUpTask_Exposure;
    /
    

    Kind regards

  • How can I restore my tabs and groups of tabs after a update to version 36.0?

    I work with many tabs when I use Firefox. I keep classified in groups of tabs, which helps to separate the different children to work I do and interests I have. I have been using this environment for years. When I started my job today, Firefox updated to v36.0, and noted the following behaviors:

    1. There is only one group of tabs when you try to display tabs at Panorama, as opposed to a dozen groups;

    2. normally if the hidden tabs (tabs in the same group as the startup group, and not the default page) downloading of content to what the user clicks on, icon, if any, and the name of the page will show on the tab currently, the tabs display 'New tab' and no icon. It seems, however, the number of tabs that exist across all groups of tabs, but are now ghosts this default value, a group of tabs. I must add, however, I do not count the number of tabs, so I can't be exactly. When you click on it, there is just a blank page. It is so strange that Firefox knows they are there but cannot simply attach the address.

    I tried to restore the following files from my backup of Windows Home Server to the folder AppData\Roaming\Mozilla\Firefox\Profiles\ .default < gobbletygook >:

    1. in the sessionstore-backups folder, I replaced the files previous.js, recovery.bak and recovery.js (not all of the upgrade ~) with the files yesterday and the day before yesterday.

    When that did nothing, I replaced

    2 sessionCheckpoints.json

    I do not see any file with a recent date that seems to be the one that I have to restore. I should add that I don't see hidden files. I thought about the restoration of the whole of the batch, but didn't know how it would affect the program v36.0 and the profile on 35.0.1 files.

    I have deadlines this week and must immediately restore my environment in order to make these possible. I have no address list on my Web pages to work in IE or other. Any help would be much appreciated.

    On a second note, I had been wondering recently if this tab group environment is an appropriate way to maintain my work environment. Sometimes, during the opening of Panorama, I would get an error saying a script takes too much time, but if I clicked on continue, it would display the groups in a few seconds. I considered bringing it in bookmarks, but it would be tedious and more difficult to access and open several tabs. Initially, I tried tabs groups thinking it was just a matter of maintaining a table of addresses (in tabs) with a name or an ID of tab group. How that might go wrong? Well, there, so it is obviously more complicated than that, and I did not know that upgrades would affect the data of a personal nature. That I should abandon the use of tab groups?

    With the help of information from the user, ptressel, in a post here on the existence of sessionstore.js when version 33 was released, I could easily get my tabs and groups of tabs as follows:

    1. close Firefox and, perhaps, wait a few seconds (30 years?) for any final closing of files;
    2. Check if you have a sessionstore.js file in your profile folder, named as I documented in my original post above.
    3. If this is not timestamped before the discovery of your problem, open the sessionstore-backups folder.
    4. Check if the recovery.js file is properly stamped and, if not, the recovery.bak.
    5. At this point, you are likely to find that none of them is before your problem occurring. If so, open your backups from this folder and go through steps 2 to 4 to find a file before your problem occurring.
    6. When you find a file, copy it to the root of your current profile folder and name it, "sessionstore.js.
    7. Open Firefox. Mine opened upwards as you wish.

    It is a solution for Windows. Sorry I can't comment on other platforms, but I'd bet it's just a copy of file and change of name, it is likely even.

    For Windows users, you can find you must sign out and sign in as administrator in order to access backups. You must not logoff your standard account, but do have Firefox closed as described above.

    Hope that helps.

  • Is it possible to save the current tabs and groups so that they can be recharged at any time?

    My Firefox crashes sometimes, and when I start it up again, my groups and tabs that I had are lost, so I need to recreate my history window. Is there a way I can save the groups that I have with the tabs on the inside so that I can retrieve them at a later date.
    "I say that Firefox does not save the whenever I close the browser, so I'm güssing there a file somewhere that contains this information, if I know how is called this file I could save it on my regular schedule and retrieve them if I had to, of course the best solution would be to have a ' save the groups ' & 'Support groups' in the menu.

    Thanks in advance
    DayoJ

    (PIN) App tabs and groups of tabs (Panorama) are stored in session data in the sessionstore.js file in the Firefox profile folder.

    You can use this button to go to the Firefox profile folder currently in use:

  • Research Protect deleted all my tabs and groups of Firefox

    I had about 200 tabs grouped together in about 30 groups of 31.0 Firefox (latest version). The Group appeared when I clicked on the icon to the left of the button "minimize" or press CTRL + SHIFT + E. It is called "your Firefox tabs - group". I also use Xmarks, but I have disabled Synchronization tab recently.

    Generally all the tabs and their groups have been saved when I closed Firefox. Today I opened Firefox and all tabs and groups disappeared! Instead, it opens some search engine called Trovi (www.trovi.com) with "bing results. Its the same in Chrome, Opera and IE.

    My OS is Windows 8.1 update 1 with all updates installed. My antivirus is Avast! with all updates installed. There was some malware installed of course, but I'm not awake me. I ran a 'full system test' in Avast! latest updates, which is the deeper analysis that I know (without my laptop HP ProBook 4730 s restaring). No viruses were found.

    I'm suspecting a program called 'Research Protect' version 2.16.10.61 'Client Connect Ltd. It was installed with PowerISO 6.0 x 64.

    I tried to run the system restore, but it seems that all the restore points I ever created are now deleted! I discovered this by opening the system properties-> system-> system restore Protection. However, 'Protection' is 'On' for my system disk.

    How can I restore my tabs and groups? It is extremely important for me.

    Accidentally, I posted my question twice - my apologies. I marked this as resolved and will continue to ask for help on the other.

    https://support.Mozilla.org/Ta/questions/1014087

    Thank you!

  • How can I remove comments from the users and groups

    I have my in my users and groups in the system preferences a user snd invited another user

    How can I remove them

    Go to Preferences system-> users and groups, and then press the lock to allow you to change the settings. Then choose 'user comments' in the sidebar and uncheck "Allow clients to connect to this computer". This will not make this option disappear, but after that you will not be able to use the Guest user.

    «Respect for the other user, simply choose it in the sidebar and press on the '-' button.» Make sure that no one uses this user.

  • tabs and groups of tabs are lost

    Closing Firefox and then restarting him, invariably all my tab groups seem to have lost their legs. Reopening of groups of Eve extended or closed (using the Group Manager add-on tab) will not help.

    It is not happened on my previous install but have since upgraded to Kubuntu 14.04 and Firefox 29 (to be precise Firefox to canonical 1.0), I keep losing my tabs and groups of tabs.

    Don't know what mistake I make.

    In case you use "clear history of Firefox closing:

    • do not erase browsing history

    Note that compensation "Preferences of Site" clears all exceptions for cookies, images, pop-up windows, installation of software, passwords, and other specific data from Web site.

    You can check for problems with the sessionstore.js and sessionstore.bak files in the profile folder of Firefox that store session data.

    Rename (or delete) the sessionstore.js file and possible sessionstore-# .js files with a number and sessionstore.bak in the Firefox profile folder.

    Delete sessionstore.js will cause App Tabs and groups of tabs open and closed tabs (back) to get lost and you will have to re-create them (take note or bookmarks if possible).

Maybe you are looking for

  • How to get credit for a movie that I rented on ITunes via my Apple TV

    Yesterday, I rented a movie on ITunes via my Apple TV. When I started to watch the movie and it turned out to be cut the Director (so every scene had an announcer describing the action). However who stated not anywhere on the news of the film until I

  • TouchSmart 14: I lost my license forever?

    Hello everyone, so I bought a laptop on one year oa year anda half previously, it came with windows 8, I've upgraded to 8.1 windows and many bugs came to the surface because of the gpu, I think, so I asked a "tech guy" to help me return to windows 8

  • Toshiba 40BV702B - where can I fix it?

    My most young threw remote on TV and now the screen has colored lines on it Anyone know where I can get a cheap replacement for this TV screen where repaired for cheap

  • Cannot Wake-on-LAN none of the 790s OptiPlex

    We have several years of OptiPlex 790 in our environment. They all have the Intel 82579LM Gigabit NIC installed. When these devices are turned off, the led "Good link" on the card NETWORK does not, and I can't wake the machines via WOL. Here's what I

  • ORA-01722: invalid number in SQL Loader

    Hi allCREATE TABLE SAMPL_TABLE(ITEM_CATEGORY VARCHAR2 (30 BYTES),ITEM_NO VARCHAR2 (240 BYTES),ITEM_DESCRIPTION VARCHAR2 (240 BYTES),CLIENT_NAME VARCHAR2 (240 BYTES),CUSTOMER_NO VARCHAR2 (240 BYTES),VALID_AMOUNT_MONTH1 NUMBER,VALID_UNITS_MONTH1 NUMBER