GROUP BY column name

Hello
Anyway is to use the group by name of colum?

Select Field1, Field2
table
Group 1, 2

Is this possible?

Hello

No this is not possible. We cannot give alias names in the group by clause.

Connected.
SQL > select deptno, sum (sal) from emp group by 1.2;
Select deptno, sum (sal) in Group emp by 1.2
*
ERROR on line 1:
ORA-00979: not a GROUP BY expression

Concerning

Tags: Database

Similar Questions

  • Error based on nested groups used by column name.

    Hi team,

    If I used the function of group nested with column name his does not work. Could you please all you suggest me.

    How to use it.

    Kind regards
    Vincent.

    Please find coil...

    SQL > select user_name, max (max (CNT)) in (select USER_NAME, count (*) NTC from v$ open_cursor group USER_NAME)
    2 group user_name, CNT;
    Select user_name, max (max (CNT)) in (select USER_NAME, count (*) NTC from v$ open_cursor group USER_NAME)
    *
    ERROR on line 1:
    ORA-00937: not a single group group function


    SQL > select max (max (CNT)) in (select USER_NAME, count (*) NTC from v$ open_cursor group USER_NAME)
    2 group of user_name;

    MAX (MAX (CNT))
    -------------
    605

    Or simply (but it would be wrong if several users have same count (*)):

    select max(USER_NAME)keep(dense_rank first order by count(*)) username
          ,max(count(*)) CNT
    from v$open_cursor
    group by USER_NAME
    
  • display the data in the column as column name

    in this column of query names are hard coded, I need to display the column name dynamically (based on sysdate). Please help me on this?

    with test_emp as

    (select 100 empno, 1st February 2014 ' hiredate, SAL union 1000 double all the)

    Select 200 empno, February 3, 2014 ", 2000 union SAL double all the"

    Select empno 300, 4 February 2014 ", 3000 union SAL double all the"

    Select 400 empno, 5 February 2014 ", 4000 SAL double

    )

    -Select * from test_emp

    SELECT EmpNo,

    Sum (decode (HireDate, trunc (sysdate), SAL, 0)) as '4 February 2014. "

    Sum (decode (HireDate, SAL, trunc(sysdate-1), 0)) as "February 3, 2014.

    Sum (decode (HireDate, trunc (sysdate)-2, SAL, 0)) as 'February 2, 2014.

    Sum (decode (HireDate, trunc (sysdate)-3, SAL, 0)) as 'February 1st, 2014. "

    Sum (decode (HireDate, trunc (sysdate)-4, SAL, 0)) as 'January 31, 2014.

    OF test_emp

    Group by empno stopped by 1

    expected results:

    EMPNO February 4, 2014 3 February 2014 2 February 2014 February 1, 2014 January 31, 2014

    100                     0                    0                       0                   1000               0

    200                     0                   2000                    0                   0                   0

    300                 3000                    0                       0                   0                   0

    400                     0                       0                       0                 0                    0

    Hello..

    We cannot manage dynamic crossover into a sql. So what I did just create a function with refcursor and get results. It will work for your case only. Try the code below and let me know in case of any problems

    FUNCTION to CREATE or REPLACE dyn_row_colum

    RETURN SYS_REFCURSOR

    AS

    v_sqlstr VARCHAR2 (32767): = ' SELECT empno, SUM (DECODE (hiredate,'|)) '''|| Trunc (sysdate) | " ((' |', sal, 0))' | ' '||'"'|| TRUNC (SYSDATE) |' » ' || «, » ;

    v_rfcur SYS_REFCURSOR;

    BEGIN

    FOR j_rec IN (SELECT col_val FROM test_emp TRUNC(SYSDATE-ROWNUM))

    LOOP

    v_sqlstr: = v_sqlstr | » '||' SUM (DECODE (hiredate,'|)) '''|| j_rec.col_val | " ((' |', sal, 0))' | ' '||'"'|| j_rec.col_val |'"' | ',';"

    END LOOP;

    v_sqlstr: = RTRIM (v_sqlstr, ','). » '||' OF test_emp GROUP BY empno';

    V_rfcur OPEN FOR v_sqlstr;

    RETURN v_rfcur;

    EXCEPTION

    WHILE OTHERS THEN

    LIFT;

    END dyn_row_colum;

    VARIABLE v_cur REFCURSOR

    EXEC: v_cur: = dyn_row_colum;

    PRINT v_cur;

    SELECT dyn_row_colum FROM dual;

    Unit tests: -.

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

    Scott@ORCL > dyn_row_colum FUNCTION to CREATE or REPLACE

    2 SYS_REFCURSOR RETURN

    3 AS

    4 v_sqlstr VARCHAR2 (32767): = ' SELECT empno, SUM (DECODE (hiredate,'|)) '''|| Trunc (sysdate) | " ((' |', sal, 0))' | ' '||'"'|| TRUNC (SYSDATE) |' » ' || «, » ;

    5 v_rfcur SYS_REFCURSOR;

    6 BEGIN

    7 FOR j_rec IN (SELECT col_val FROM test_emp TRUNC(SYSDATE-ROWNUM))

    8 LOOP

    9 v_sqlstr: = v_sqlstr | » '||' SUM (DECODE (hiredate,'|)) '''|| j_rec.col_val | " ((' |', sal, 0))' | ' '||'"'|| j_rec.col_val |'"' | ',';"

    10 END OF LOOP;

    11 v_sqlstr: = RTRIM (v_sqlstr, ','). » '||' OF test_emp GROUP BY empno';

    12 v_rfcur OPEN FOR v_sqlstr;

    13 RETURN v_rfcur;

    14 EXCEPTION

    15 SO THAT OTHERS THEN

    16 RAISE;

    17 END dyn_row_colum;

    18.

    The function is created.

    Scott@ORCL > v_cur VARIABLE REFCURSOR

    Scott@ORCL > EXEC: v_cur: = dyn_row_colum;

    PL/SQL procedure successfully completed.

    Scott@ORCL > v_cur PRINT;

    EMPNO 5 FEBRUARY 14 FEBRUARY 4, 14 3 FEBRUARY 14 FEBRUARY 2 14 1 FEBRUARY 14

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

    100          0          0          0          0       1000

    400       4000          0          0          0          0

    300          0       3000          0          0          0

    200          0          0       2000          0          0

    Scott@ORCL > dyn_row_colum SELECT FROM dual;

    DYN_ROW_COLUM

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

    CURSOR STATEMENT: 1

    CURSOR STATEMENT: 1

    EMPNO 5 FEBRUARY 14 FEBRUARY 4, 14 3 FEBRUARY 14 FEBRUARY 2 14 1 FEBRUARY 14

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

    100          0          0          0          0       1000

    400       4000          0          0          0          0

    300          0       3000          0          0          0

    200          0          0       2000          0          0

  • name of group/prot-vmhost name / vlan id /Swicth

    Get-vmhost xxx | Get-VirtualPortGroup more or less gives me what I need

    But I'm looking for format like this

    name of group/prot-vmhost name / vlan id /Swicth

    I need this o/p to have include VMhost name 1st column & also run for all the vmhost in a cluster. Can someone do this

    It is a way to do

    Get-VMHost-xxx name | Get-VirtualPortGroup |

    Select-Object - property @{N = "HostName"; E = {Get-VMhost-Id $_.} VMhostid | {{Select - ExpandProperty name}}.

    @{N = "PortgroupName"; E={$_. Name}}, VLanId, VirtualSwitchName

  • Extraction of values based on column names

    Hello

    I have three tables. Table A table contains a column with all column_names in the table b. table B is to have an emp_id and other fields that are stored as values in the column of the TABLE.  I need to get the emp_id and value from the column of table B based on data of Table A. and store it in another table.

    Example:

    Table has -col1

    Emp_name

    Emp_sal

    Emp_dept

    Table B

    Emp_id Emp_name Emp_sal Emp_dept

    1001 ABC 1000 sales

    1002 XYZ 2000 SVC

    TABLE C

    Emp_id Emp_details value

    1001 Emp_name ABC

    1001 Emp_sal 1000

    1001 Emp_dept sales

    1002 Emp_name XYZ

    1002 Emp_sal 2000

    1002 Emp_dept SVC

    Using the list of TABLE A, I have to select each Id and corresponding to the value of TABLE B and even insert in TABLE C. I know that we can use a loop for, but I have trouble choosing the name of column based on the value of the slider. Can anyone help?


    Hello

    Looks like you want to do 2 things rather difficult:

    (1) unpivot data from several columns in the column 1 value

    (2) get the column names for the another table unpivot operator

    Let's start with how you could do just part 1, unpivoting data:

    INSERT INTO table_c (emp_id, emp_details, value)

    WITH all_varchar2 AS

    (

    SELECT emp_id

    emp_name

    TO_CHAR (emp_sal) AS emp_sal

    emp_dept

    --Include all columns, you might need

    OF table_b

    )

    SELECT emp_id, emp_details, value

    Of all_varchar2

    UNPIVOT (value

    FOR emp_details IN

    (emp_name - dynamic

    emp_sal - dynamic

    emp_dept - dynamic

    )

    )

    ;

    Value is a column, everything happens in this column must have the same (or a very similar) data type.  The subquery all_varchar2 converts all columns that you can rotate in VARCHAR2s (if they are not already VARCHAR2s) so that they are ready to rotate.  You might consider doing a permanent display for this.

    Now, instead of hard-Ghoshal the 3 line marked "Dynamics", you seek to table_a.  You will know beforehand what are these columns, and you won't even know there will be the number of columns. You need instructions SQL dynamic to write this part of the INSERT statement for you at run time.

    Here's a way to do it in SQL * more and SQL:

    -The preliminary motion

    COLUMN col_list_col by col_list new_value

    SELECT LISTAGG (col1, ',') within THE GROUP (ORDER BY col1)

    AS col_list_col
    FROM table_a;

    -Main return (dynamic):

    INSERT INTO table_c (emp_id, emp_details, value)
    WITH all_varchar2 AS
    (
    SELECT emp_id
    emp_name
    TO_CHAR (emp_sal) AS emp_sal
    emp_dept
    --Include all columns, you might need
    OF table_b
    )
    SELECT emp_id, emp_details, value
    Of all_varchar2
    UNPIVOT (value
    FOR emp_details IN
    (& col_list
    )
    )
    ;

    Dynamic SQL often works like this.  First, you make a preliminary motion to write the part that is not know before execution.  Then, you run the main statement, which has the integrated preliminary query results.

    If you do this in PL/SQL, you use a string variable ordinary for col_list, instead of a substitution variable.

  • Error in the COLMAP clause. Column name not found

    Hi guys,.

    I must be missing something simple here, but I can't understand it. I have a very simple test, I am trying to make. Remap the 1 table column in the other on replicat.

    I created the file defgens.
    *
    * Definitions created/modified 2013-02-12 13:08
    *
    * Description of the areas for each entry in the column:
    *
    * 1 name
    * Data type 2
    * 3 external length
    * Fetch 4 Offset
    * Level 5
    * 6 level
    * 7 null
    * 8 so strange bump
    * Inner length 9
    * 10 binary length
    * Length of the table 11
    * 12 most significant DT
    * 13 least significant DT
    * 14 high precision
    * 15 little specific
    * 16 point elementary
    * Occurs 17
    * Column 18 key
    * Data type of void 19
    *
    *
    Definition of table of BILLING. B1
    Length: 92
    SYSKEY: 0
    Columns: 2
    B_ID 64 50 0 0 0 1 0 50 50 50 0 0 0 0 1 0 1 2
    B_F_NAME 64 30 56 0 0 1 0 30 30 0 0 0 0 0 1 0 0 0
    End of definition
    *
    Definition of table of BILLING. B2
    Length: 92
    SYSKEY: 0
    Columns: 2
    B_ID 64 50 0 0 0 1 0 50 50 50 0 0 0 0 1 0 1 2
    B_L_NAME 64 30 56 0 0 1 0 30 30 0 0 0 0 0 1 0 1 0
    End of definition


    I installed the replicat read the sourcedefs and remap the columns

    -Identify the Replicat group:
    REPLICAT rxtest
    -State that the source and target definitions are identical:
    -ASSUMETARGETDEFS
    SOURCEDEFS /u12/oracle/golden_gate_11_rep/dirsql/defgen_billing.sql
    -Delete the installation program
    DISCARDFILE u12/oracle/golden_gate_11_rep/dirout/rxtest.txt, SERVING
    SETENV (NLS_LANG = 'AMERICAN_AMERICA. WE8MSWIN1252")
    -Specify the database connection information as needed for the database:
    GG username, password
    -Specify the error handling rules:
    REPERROR (BY DEFAULT, ABEND)

    DDL EXCLUDE ALL THE

    Billing.b1, billing.r1 of the TARGET CARD,
    () COLMAP
    B_ID = id,
    b_f_name = what);

    Now, when I try and start replicat rxtest I get this error in the report.

    Resolved CARD (entry of BILLING. (B1):
    THE CARD BILLING. B1, TARGET billing.r1, COLMAP (B_ID = id b_f_name = what);
    ... (B_ID = id b_f_name = what...)
    ^
    Error in the COLMAP clause. Column name not found.

    Any ideas? Thank you

    And the ranking of the column names in your clause of colmap? If that is not reversed?

  • IN parameter is the string of column names I want to SELECT delimited

    Hi guys,.

    Please bare with me. Not a pro at writing stored procedures.

    What I try to do is to pass a parameter of 'IN' to the proc. The setting is a varchar2 which is a comma-delimited string.
    I want to put this string in the SELECT statement.

    This setting is called "P_SelectFields".

    The value in the passage in the proc is like:
    P_SelectFields = ' CUSTOMERS SUM (CLI_SERVED) AS SUM (EI_INTC) + SUM (NEI_INTC) AS INTERVENTIONS,
    SUM (TOT_EMPRTN) AS EMP_RETURN, SUM (TOTAL_RTS) AS SCHOOL_RETURN
    "


    That's what I've got and I know that it works, if I put the string instead of the parameter it works. !

    PROCEDURE GET_NATIONAL_TOTAL_RESULTS (P_SelectFields IN varchar2, P_AGREEMENT_TYPE_IND AGREEMENT_TYPE.agreement_type_ind%TYPE, io_cursor in SYS_REFCURSOR)
    IS
    BEGIN
    OPEN FOR Io_cursor

    SELECT year_desc,
    P_SelectFields - that's where I want my partameter go.

    OF SPF_RESULT_VW
    WHERE r_num = 1 - FILTER for the LAST PERIOD for EACH YEAR
    and agreement_type_ind = P_AGREEMENT_TYPE_IND - desired FILTER FOR Agreement_type_ind
    GROUP BY year_desc
    ORDER BY year_desc
    ;

    END GET_NATIONAL_TOTAL_RESULTS;


    That's what I'm after you run the proc.

    YEAR_DESC = 2011-2012
    : B2 = SUM (CLI_SERVED) ACE, SUM (EI_INTC) CUSTOMERS + EMP_RETURN SUM (NEI_INTC) AS OF THE INTERVENTIONS, SUCH AS SUM (TOT_EMPRTN), SUM (TOTAL_RTS) SCHOOL_RETURN

    Where is ': B2 = "come from?".

    What can I do to make my parameter is "picked up" by the proc?

    Thank you

    Firstly: in relational databases, there is no distinction between 'fields '. Tables is not 'fields', they have columns.
    It is my experience that that call columns 'fields' basically treats the database as a flat file system. It's a very bad idea!

    If you want to pass as a parameter column names, you need dynamic SQL.
    However, PL/SQL was invented to reduce the analysis and using of the dynamic SQL, you'll at least soft-parse each statement.

    Dynamic SQL is obviously in the documentation, but most people here think that they don't need to read the documentation.

    So, for once
    glance

    OPEN io_cursor FOR
    'SELECT year_desc,'||
    P_SelectColumns||
    ' FROM SPF_RESULT_VW '||
    'WHERE r_num = 1 '|| --FILTER FOR LATEST PERIOD FOR EACH YEAR
    'and agreement_type_ind = P_AGREEMENT_TYPE_IND '||-- FILTER FOR desired Agreement_type_ind
    'GROUP BY year_desc '||
    'ORDER BY year_desc'
    ;
    

    Please note that I have renamed the parameter.

  • How to select data using the same remote database column name 3

    Hello


    Can anyone help me on how to get the data with the same remote database column names 3 and a unique nickname.

    E.g.

    SELECT *.
    B.SID, b.status, SUM (b.qty) qantity MAX (b.) date_as_of
    Of
    * ((table1@remotedatabase1, table1@remotedatabase2, table1@remotedatabase3) has, *)
    (* (table1@remotedatabase1, table1@remotedatabase2, table1@remotedatabase3) b). *
    WHERE b.dept = 'finance '.
    AND a.position = "admin".
    AND a.latest = 'Y' AND (b.status <>"MLT") AND b.qty > 0;
    B.SID GROUP, b.status;

    NOTE: the instructions "BOLD" is just an example of what I want to do but I always get an error beacause of ambiguous column.

    Thanks to advnce. :)

    Published by: user12994685 on 4 January 2011 21:42

    user12994685 wrote:

    Can anyone help me on how to get the data with the same remote database column names 3 and a unique nickname.

    Not valid. This makes no sense and breaks all the rules of scope-resolution. And if it is in a single database, or uses tables in databases, is not relevant.

    Each object must be particularly well identified. If you cannot do this:

    select * from (table1@remotedatabase1, table1@remotedatabase2, table1@remotedatabase3) a
    

    3 objects cannot share the same alias. Example:

    SQL> select * from (dual, dual) d;
    select * from (dual, dual) d
                       *
    ERROR at line 1:
    ORA-00907: missing right parenthesis
    

    You need to combine objects - by using a join union or similar. He will have to be done as follows:

    SQL> select * from (select * from dual d1, dual d2) d;
    select * from (select * from dual d1, dual d2) d
           *
    ERROR at line 1:
    ORA-00918: column ambiguously defined
    

    However, we need to have unique column in a projection of SQL names - so the join of the need to project a unique set of columns. So:

    SQL> select * from (select d1.dummy as dummy1, d2.dummy as dummy2 from dual d1, dual d2) d;
    
    DUM DUM
    --- ---
    X   X
    
    SQL> 
    

    I suggest that you look carefully at what opportunities are and how it applies in SQL - and ignore if the referenced objects are local or remote, because it has no effect on the basic principles of scope-resolution.

  • Compare column names

    I have two tables with similar columns.
    Is there a way to check if the two tables have column same names regardless of the order of the columns?
    select  column_name
      from  user_tab_columns
      where table_name in ('table1','table2')
      group by column_name
      having count(*) = 1
    /
    

    I will give you a list of all the columns that exist only in one of the tables. If the column names are the same, it will return no data found.

    SY.

  • ORA-01730: number of column names specified invalid

    I am trying to create a view. The select statement by itself works very well. The create view statement becomes an error ORA-01730.

    SQL > CREATE OR REPLACE VIEW STAFFING. V_FORECAST_EXCEPTION_XTAB
    2 AS
    3. SELECT
    V_EMPLOYEE_FORECAST_EXCEPTION 4. EMPLOYEE_NAME,
    V_EMPLOYEE_FORECAST_EXCEPTION 5. AFC,
    6 V_EMPLOYEE_FORECAST_EXCEPTION. COST_CENTER,
    V_EMPLOYEE_FORECAST_EXCEPTION 7. FUNDS,
    V_EMPLOYEE_FORECAST_EXCEPTION 8. PAY_PLAN,
    CURRENT_FY.FY 9,.
    10 SUM (DECODE (MV_PAYROLL_CY. PP, 21, MV_PAYROLL_CY. PAY_AMT, 0)) PP21.
    11 SUM (DECODE (MV_PAYROLL_CY. PP, 22, MV_PAYROLL_CY. PAY_AMT, 0)) PP22,.
    12 SUM (DECODE (MV_PAYROLL_CY. PP, 23, MV_PAYROLL_CY. PAY_AMT, 0)) PP23,.
    13 SUM (DECODE (MV_PAYROLL_CY. PP, 24, MV_PAYROLL_CY. PAY_AMT, 0)) PP24,.
    14 SUM (DECODE (MV_PAYROLL_CY. PP, 25, MV_PAYROLL_CY. PAY_AMT, 0)) PP25.
    15 SUM (DECODE (MV_PAYROLL_CY. PP, 26, MV_PAYROLL_CY. PAY_AMT, 0)) PP26,.
    16 SUM (DECODE (MV_PAYROLL_CY. PP, 1, MV_PAYROLL_CY. PAY_AMT, 0)) PP01.
    17 SUM (DECODE (MV_PAYROLL_CY. PP, 2, MV_PAYROLL_CY. PAY_AMT, 0)) PP02.
    18 SUM (DECODE (MV_PAYROLL_CY. PP, 3, MV_PAYROLL_CY. PAY_AMT, 0)) PP03,.
    19 SUM (DECODE (MV_PAYROLL_CY. PP, 4, MV_PAYROLL_CY. PAY_AMT, 0)) PP04,.
    SUM (DECODE (MV_PAYROLL_CY 20. PP, 5, MV_PAYROLL_CY. PAY_AMT, 0)) PP05,.
    21 SUM (DECODE (MV_PAYROLL_CY. PP, 6, MV_PAYROLL_CY. PAY_AMT, 0)) INTRODUCED PP06.
    SUM (DECODE (MV_PAYROLL_CY 22. PP, 7, MV_PAYROLL_CY. PAY_AMT, 0)) PP07,.
    23 SUM (DECODE (MV_PAYROLL_CY. PP, 8, MV_PAYROLL_CY. PAY_AMT, 0)) PP08,.
    24 SUM (DECODE (MV_PAYROLL_CY. PP, 9, MV_PAYROLL_CY. PAY_AMT, 0)) PP09,.
    25 SUM (DECODE (MV_PAYROLL_CY. PP, 10, MV_PAYROLL_CY. PAY_AMT, 0)) PP10,.
    SUM (DECODE (MV_PAYROLL_CY 26. PP, 11, MV_PAYROLL_CY. PAY_AMT, 0)) PP11,.
    27 SUM (DECODE (MV_PAYROLL_CY. PP, 12, MV_PAYROLL_CY. PAY_AMT, 0)) PP12,
    28 SUM (DECODE (MV_PAYROLL_CY. PP, 13, MV_PAYROLL_CY. PAY_AMT, 0)) PP13,.
    29 SUM (DECODE (MV_PAYROLL_CY. PP, 14, MV_PAYROLL_CY. PAY_AMT, 0)) PP14.
    30 SUM (DECODE (MV_PAYROLL_CY. PP, 15, MV_PAYROLL_CY. PAY_AMT, 0)) PP15,.
    SUM (DECODE (MV_PAYROLL_CY 31. PP, 16, MV_PAYROLL_CY. PAY_AMT, 0)) PP16,.
    32 SUM (DECODE (MV_PAYROLL_CY. PP, 17, MV_PAYROLL_CY. PAY_AMT, 0)) PP17,.
    33 SUM (DECODE (MV_PAYROLL_CY. PP, 18, MV_PAYROLL_CY. PAY_AMT, 0)) PP18,.
    34 SUM (DECODE (MV_PAYROLL_CY. PP, 19, MV_PAYROLL_CY. PAY_AMT, 0)) PP19,.
    35 SUM (DECODE (MV_PAYROLL_CY. PP, 20, MV_PAYROLL_CY. PAY_AMT, 0)) PP20
    36 FROM
    V_EMPLOYEE_FORECAST_EXCEPTION 37,
    CURRENT_FY 38,
    39 MV_PAYROLL_CY
    40. WHERE THE
    V_EMPLOYEE_FORECAST_EXCEPTION.FY 41 = CURRENT_FY.FY
    42 AND V_EMPLOYEE_FORECAST_EXCEPTION. EMPLOYEE_NAME = MV_PAYROLL_CY. EMP_NAME
    43 AND V_EMPLOYEE_FORECAST_EXCEPTION. COST_CENTER = SUBSTR (MV_PAYROLL_CY.ORG_CODE, 1, 6)
    44 AND V_EMPLOYEE_FORECAST_EXCEPTION. FUND = MV_PAYROLL_CY. FUND
    45 AND V_EMPLOYEE_FORECAST_EXCEPTION. PAY_PLAN = MV_PAYROLL_CY. PAY_PLAN
    46 AND V_EMPLOYEE_FORECAST_EXCEPTION.FY = MV_PAYROLL_CY.FY
    47 AND V_EMPLOYEE_FORECAST_EXCEPTION. PP = MV_PAYROLL_CY. PP
    48 AND V_EMPLOYEE_FORECAST_EXCEPTION. AFC = SUBSTR (MV_PAYROLL_CY. SAC, 3, 2)
    49 GROUP BY
    50 V_EMPLOYEE_FORECAST_EXCEPTION. EMPLOYEE_NAME,
    51 V_EMPLOYEE_FORECAST_EXCEPTION. AFC,
    52 V_EMPLOYEE_FORECAST_EXCEPTION. COST_CENTER,
    53 V_EMPLOYEE_FORECAST_EXCEPTION. FUNDS,
    54 V_EMPLOYEE_FORECAST_EXCEPTION. PAY_PLAN,
    55 CURRENT_FY.FY;
    SUM (DECODE (MV_PAYROLL_CY. PP, 21, MV_PAYROLL_CY. PAY_AMT, 0)) PP21.
    *
    ERROR on line 10:
    ORA-01730: number of column names specified invalid

    More likely [Bug 3040464 - defined views as ALIAS.* selection should be expanded | https://metalink2.oracle.com/metalink/plsql/ml2_documents.showDocument?p_database_id=NOT&p_id=3040464.8]

    SY.

  • As a dynamic values column names

    I have a WEEK_TAB table

    Week_num Bkg1 Bkg2
    1 10 20
    2 40 10
    3 30 20
    2 20 60
    1-10-50
    1-20-80
    3 10 30

    When I run this package, I get the below output...

    CREATE OR REPLACE
    PACKAGE GET_TOTAL AS

    TYPE ref_cursor IS REF CURSOR;

    PROCEDURE get_week_total (p_refCursor to ref_cursor);

    PROCEDURE get_total_val;

    END GET_TOTAL;
    /

    CREATE OR REPLACE
    PACKAGE BODY GET_TOTAL AS

    PROCEDURE get_week_total (p_refCursor to ref_cursor) AS
    BEGIN
    OPEN FOR P_refcursor
    SELECT SUM (bkg1), week_num
    OF week_tab
    GROUP BY week_num
    ORDER BY week_num;
    END get_week_total;

    PROCEDURE get_total_val AS
    v_refCursor ref_cursor;
    v_sum NUMBER;
    v_week NUMBER;
    v_total NUMBER: = 0;

    BEGIN

    get_week_total (v_refcursor);

    LOOP
    EXTRACTION v_refCursor
    IN v_sum, v_week;
    EXIT WHEN v_refcursor % NOTFOUND;
    v_total: = v_total + v_sum;
    DBMS_OUTPUT. Put_line (' week ' | v_week |': ' | v_sum);
    END LOOP;
    DBMS_OUTPUT. Put_line (' total sales reservations :'|| v_total);
    END get_total_val;

    END GET_TOTAL;
    /

    O/P
    Week 01:40
    Week
    Week 03:40
    Total sales reservations: 140

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

    Here, I'm moving the column name as dynamic value.
    I modified the package as below...

    CREATE OR REPLACE
    PACKAGE BODY GET_TOTAL AS

    CREATE OR REPLACE
    PACKAGE GET_TOTAL AS

    TYPE ref_cursor IS REF CURSOR;

    Strarray ARRAY TYPE IS VARCHAR2 (100);

    PROCEDURE get_week_total)
    p_colName VARCHAR2,
    p_refCursor to ref_cursor);

    PROCEDURE get_total_val;

    END GET_TOTAL;
    /

    CREATE OR REPLACE
    PACKAGE BODY GET_TOTAL AS

    PROCEDURE get_week_total)
    p_colName IN VARCHAR2,
    p_refCursor OUT ref_cursor) AS

    v_query VARCHAR2 (4000);
    BEGIN
    v_query: = ' SELECT SUM (: p), week_num FROM week_tab GROUP BY week_num ORDER BY week_num';

    P_refcursor OPEN FOR v_query
    Using p_colName;

    END get_week_total;

    PROCEDURE get_total_val AS
    v_refCursor ref_cursor;
    v_sum NUMBER;
    v_week NUMBER;
    v_total NUMBER: = 0;
    STRARRAY v_colName: = STRARRAY ('BKG1', 'BKG2');

    BEGIN

    I'm IN v_colName.FIRST... v_colName.Last LOOP
    get_week_total (v_colName (i), v_refcursor);

    LOOP
    EXTRACTION v_refCursor
    IN v_sum, v_week;
    EXIT WHEN v_refcursor % NOTFOUND;
    v_total: = v_total + v_sum;
    DBMS_OUTPUT. Put_line (' week ' | v_week |': ' | v_sum);
    END LOOP;
    DBMS_OUTPUT. Put_line (' total sales reservations :'|| v_total);

    END LOOP;
    END get_total_val;

    END GET_TOTAL; GET_TOTAL;
    /


    But I get this error message
    ORA-01722: invalid number
    ORA-06512: at "SCOTT. GET_TOTAL', line 29
    ORA-06512: at line 2


    Please let me know how this can be resolved... I'm trying to get the result as below

    Week 01:40
    Week
    Week 03:40
    Total sales reservations: 140

    Week 1:150
    Week 2:70
    Week 03:50
    Total sales reservations: 270

    Variable bind bind values of the object, not the object names. You cannot use bind variable as column name. Change:

    v_query := 'SELECT SUM (:p), week_num FROM week_tab GROUP BY week_num ORDER BY week_num'; 
    

    TO

    v_query := 'SELECT SUM (' || p_colName || '), week_num FROM week_tab GROUP BY week_num ORDER BY week_num'; 
    

    and

    OPEN p_refcursor FOR v_query
    USING p_colName; 
    

    TO

    OPEN p_refcursor FOR v_query; 
    

    SY.

  • Columns of folder: by default, how can return the first column 'Name' without having to move it manually every time?

    Something's happened awhile and when I create a folder which appears the first column is the column 'Date modified '. By default, how can return the first column 'Name' without having to move it manually every time?

    Hello

    I suggest you to visit these links and check if it helps:

    http://Windows.Microsoft.com/en-us/Windows-Vista/working-with-files-and-folders#section_4

    http://Windows.Microsoft.com/en-us/Windows-Vista/folders-frequently-asked-questions

    It will be useful.

  • Contact - removal of the entire group and its name.

    In Vista, I can delete individual members of a group, but how to remove the group bearing his name. Tried all I know. Help!  Thanks adavance if you can spare the time to calm down a user of profanity.

    It is clear. That's also what I thought that you said in your original post. If I gave you this...
    Assuming you are using Windows Mail...
    Open Windows Mail > toolbar, click Contacts > highlight the group in question, right click > delete see screenshot for illustration:
    For the benefits of others looking for answers, please mark as answer suggestion if it solves your problem.

  • Is if possible to group files by name and display for each letter instead of "A - H"?

    Is if possible to group files by name and display for each letter instead of "A - H"?

    Hello

    I don't think that there is a way to group all the numbers/letters individually.

    Grouping like this would appear likely several empty sections, since not all files will have file names that begin with all 26 letters.

    There are several ways that you can view the files by name, for example, list, details, category, etc.

    Concerning

  • Display the name of the tag as the column name and the value in the tag as a row of data from the input string.

    Hi Forum members,

    I am looking for a query display the name of the tag as the column name and the value in the tag as a row of data.

    I have to print the values within the tag to a file by choosing the value of the flags. the sequence of the tags will vary each time, as the tag name will change dynamically.

    So here is the example of input data and the expected output. The string in the text column must be separated as the column names and values.

    Input data
    Select 1 as seqno,' < > 0210A 50 4f < / 4f > < 5f20 > TEST CARD 16 < / 5f20 > < 5f2a > < / 5f2a > < 82 > 1 c 00 < / 82 > ' double text


    Output:

    Seqno 4f 5f20 5f2a 82
    0210A 50 16 1 00 TEST CARD 1

    Please help me by providing your entries on this.

    We use the version of Oracle 11.2.

    Note: This is not the XML string

    Thank you

    Shree

    with

    data in the form of

    (select 1 as seqno,'<4f>0210 A 50<5f20>TEST CARD 16<5F2a><82>00 1' text of all the double union)

    Select 2 as seqno,'XYZ<4F>0210 A 50<5f20>TEST CARD 16<5f2a><82>00 1' text of all the double union

    Select 3 as seqno,'<4f>0210 A 50<5f20>TEST CARD 16<5F2A><82>1 00XYZ ' text of all the double union

    Select option 4 as seqno,'<4F>0210 A 50<5F20>TEST CARD 16<5f2A><82>1 00XYZ' double text

    )

    Select d.seqno, x.*

    d the data,

    XMLTable ('/ root')

    by the way xmltransform (xmltype ('': replace (replace (text,'<><>'),)))

    XmlType (q'~http://www.w3.org/1999/XSL/Transform "version ="1.0"> ")

                                                     

                                                       

                                                         

                                                       

                                                     

                                                     

                                                       

                                                         

                                                       

                                                     

    ~'

    )

    )

    path of columns '4f' varchar2 (10) "tag4f."

    path of "5f20' varchar2 (30)"tag5f20. "

    path of '5f2a' varchar2 (10) "tag5f2a."

    path of varchar2 (10) "82" "tag82.

    ) x


    SEQNO 4f 5f20 5f2a 82
    1 0210A 50 16 TEST CARD - 1 00
    2 0210A 50 16 TEST CARD - 1 00
    3 0210A 50 16 TEST CARD - 1 00
    4 0210A 50 16 TEST CARD - 1 00

    with

    data in the form of

    (select 1 as seqno,'<4f>0210 A 50<5f20>TEST CARD 16<5F2a><82>00 1' text of all the double union)

    Select 2 as seqno,'XYZ<4F>0210 A 50<5f20>TEST CARD 16<5f2a><82>00 1' text of all the double union

    Select 3 as seqno,'<4f>0210 A 50<5f20>TEST CARD 16<5F2A><82>1 00XYZ ' text of all the double union

    Select option 4 as seqno,'<4F>0210 A 50<5F20>TEST CARD 16<5f2A><82>1 00XYZ' double text

    ),

    Chopper (seqno, Key, value, String) as

    (select seqno,

    regexp_substr (text,'<(.+?)>', 1, 1, null, 1),

    regexp_substr (Text,'>(.*?))

    regexp_substr (text,'<.+?>. *? ) (.*) $', 1, 1, null, 1). » <>'

    from the data

    Union of all the

    Select seqno,

    regexp_substr (String,'<(.+?)>', 1, 1, null, 1),

    regexp_substr (String,'>(.*?))

    regexp_substr (String,'<.+?>. *? ) (.*) $', 1, 1, null, 1)

    Chopper

    where regexp_substr (string,'<(.*?)>', 1, 1, null, 1) is not null

    )

    Select '4f', seqno, '5f2a', '82', '5f20.

    of (seqno, lower (key) select key, value)

    Chopper

    )

    Pivot (max (value) for key in ('4f' as '4f', '5f20' as '5f20', '5f2a' as '5f2a', "82" as "82"))

    Concerning

    Etbin

Maybe you are looking for