Error using group by expression
hello friends,
I use this query & used group by but oracle give error :
ORA-00979: not a GROUP BY expression
Select uu.ID,max(uu.module_name) as MainMenu,uu.NAME,decode(substr(param_str,4,1), 'P','ü','') as Allow,decode(substr(param_str,1,1), 'A','ü','') as Ins,decode(substr(param_str,2,1), 'E','ü','') as Edit,decode(substr(param_str,3,1), 'D','ü','') as Del from USER_MODULE uu,user1 where( user_name='SA'or user_name is null)and user1.srno=uu.srno and uu.ID=uu.ID group by uu.id,uu.name,MainMenu group by uu.id,uu.name
Hi
The 'param_str' in DECODE function either should be a bind variable for user input or should be a column of a table. If it is a table/view column then include it in the GROUP BY clause and the query should work.
If you specify a GROUP BY clause in a statement, then the select list can
contain only the following types of expressions:
– GROUP BY expressions
– Constants
– Aggregate functions and the functions USER, UID, and SYSDATE
– Expressions identical to those in the group_by_clause. If the group_by_
clause is in a subquery, then the GROUP BY columns of the subquery must
match the select list of the outer query. Any columns in the select list of the
subquery that are not needed by the GROUP BY operation are ignored without
error.
– Expressions involving the preceding expressions that evaluate to the same
value for all rows in a group
In short, except for the columns in aggregate functions, all columns must be included in the GROUP BY clause.
- Priya
Similar Messages
-
Syntax Error - Using "Group By" with "Union All"
Dear SAP community, I am a newb in need of help.
Just spent the past 2 days searching for answers on how to build this query.
Basically, I just want to group the Item Names (U_ItemName) together and have their respective quantities (U_Cart) added together so the same items display as one total quantity, no duplicates.
I have tried so many combinations of GroupBy and Sum/Count....etc. Nothing is working.
The query:
SELECT T1.[U_ItemName] AS 'Item Name', T1.[U_Cart] AS 'Cartons Available', T0.[Country] AS 'Country', T1.[U_ShlfLife] AS 'Shelf Life' FROM [dbo].[OWHS] T0 inner join [dbo].[@SICAS_EXT_WHS] T1 on T0.WhsCode=T1.U_WhseCode WHERE T0.[Country] = (N'JP' ) and DateDiff(Month, GetDate(),T1.[U_ShlfLife]) <= 6 union all
SELECT T0.[U_ItemName], Sum(T0.[U_Cart]) as Cartons, T1.[Country], null FROM [dbo].[@SICAS_EXT_WHS] T0, OWHS T1 WHERE T1.[Country] = (N'JP' ) and DateDiff(Month, GetDate(),T0.[U_ShlfLife]) >= 6
GROUP BY T0.[U_ItemName], T0.[U_Cart], T1.[Country]
Can anybody advise how to get this working?
Thank you,
Justice Nerenberghi justice,
I checked your code and it seems correct. but I don't have same table in database so i can't check it correctly.
but I tried your problem with same situation and I am getting actual result.
Example :-
select itemcode,dscription,quantity from inv1
where docdate>'2011-02-18 00:00:00.000'
union all
select itemcode,dscription,Sum(quantity) from inv1
where docdate<'2011-02-18 00:00:00.000'
group by itemcode,dscription
Please do one thing rum both select queries separately whether running properly. Using above example you can check your code
Thanks
Annu -
"not a GROUP BY expression" error when using EclipseLink
I'm using EcliseLink 2.3.0
The follow SQL can be executed successfully.
select to_char(o.taskDate, 'YYYY/MM'), sum(o.plannedHrs) from TaskItem o group by to_char(o.taskDate, 'YYYY/MM');
But the JPQL has an error when it gets excuted.
select FUNC('to_char', o.taskDate, 'YYYY/MM'), sum(o.plannedHrs) from TaskItem o group by FUNC('to_char', o.taskDate, 'YYYY/MM')
ERROR LOG:
Local Exception Stack:
Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.3.0.v20110604-r9504): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLSyntaxErrorException: ORA-00979: not a GROUP BY expression
Error Code: 979
Call: SELECT to_char(TASK_DATE, ?), SUM(PLANNED_HRS) FROM ORA47111.S_PROJ_PLAN_ITEM GROUP BY to_char(TASK_DATE, ?)
bind => [2 parameters bound]
Query: ReportQuery(referenceClass=TaskItemDAO sql="SELECT to_char(TASK_DATE, ?), SUM(PLANNED_HRS) FROM ORA47111.S_PROJ_PLAN_ITEM GROUP BY to_char(TASK_DATE, ?)")
at org.eclipse.persistence.exceptions.DatabaseException.sqlException(DatabaseException.java:333)
at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:644)
at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeCall(DatabaseAccessor.java:535)
at org.eclipse.persistence.internal.sessions.AbstractSession.basicExecuteCall(AbstractSession.java:1702)
at org.eclipse.persistence.sessions.server.ServerSession.executeCall(ServerSession.java:566)
at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:207)
at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:193)
at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeSelectCall(DatasourceCallQueryMechanism.java:264)
at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.selectAllRows(DatasourceCallQueryMechanism.java:646)
at org.eclipse.persistence.internal.queries.ExpressionQueryMechanism.selectAllRowsFromTable(ExpressionQueryMechanism.java:2592)
at org.eclipse.persistence.internal.queries.ExpressionQueryMechanism.selectAllReportQueryRows(ExpressionQueryMechanism.java:2535)
at org.eclipse.persistence.queries.ReportQuery.executeDatabaseQuery(ReportQuery.java:846)
at org.eclipse.persistence.queries.DatabaseQuery.execute(DatabaseQuery.java:829)
at org.eclipse.persistence.queries.ObjectLevelReadQuery.execute(ObjectLevelReadQuery.java:1056)
at org.eclipse.persistence.queries.ReadAllQuery.execute(ReadAllQuery.java:390)
at org.eclipse.persistence.queries.ObjectLevelReadQuery.executeInUnitOfWork(ObjectLevelReadQuery.java:1144)
at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.internalExecuteQuery(UnitOfWorkImpl.java:2863)
at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1501)
at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1483)
at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1457)
at org.eclipse.persistence.internal.jpa.EJBQueryImpl.executeReadQuery(EJBQueryImpl.java:485)
at org.eclipse.persistence.internal.jpa.EJBQueryImpl.getResultList(EJBQueryImpl.java:742)
at projapis.projrollup.beans.ManagedTaskItemDAOBean.calcResourcePlannedHrsInMonth(ManagedTaskItemDAOBean.java:329)
at projapis.projrollup.beans.ManagedTaskItemDAOBean.main(ManagedTaskItemDAOBean.java:522)
Caused by: java.sql.SQLSyntaxErrorException: ORA-00979: not a GROUP BY expression
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:440)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:396)
at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:837)
at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:445)
at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:191)
at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:523)
at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:207)
at oracle.jdbc.driver.T4CPreparedStatement.executeForDescribe(T4CPreparedStatement.java:863)
at oracle.jdbc.driver.OracleStatement.executeMaybeDescribe(OracleStatement.java:1153)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1275)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3576)
at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3620)
at oracle.jdbc.driver.OraclePreparedStatementWrapper.executeQuery(OraclePreparedStatementWrapper.java:1491)
at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeSelect(DatabaseAccessor.java:931)
at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:607)
... 22 more
Any suggestion?
Thanks a lot.
Edited by: sgao on Jul 19, 2011 11:13 PMHello,
Unfortunately it is the driver complaining about the SQL that is generated, but I see no major difference from the SQL in the exception:
SELECT to_char(TASK_DATE, ?), SUM(PLANNED_HRS) FROM ORA47111.S_PROJ_PLAN_ITEM GROUP BY to_char(TASK_DATE, ?)
and the SQL you state works other than it looks like JPQL not SQL: select to_char(o.taskDate, 'YYYY/MM'), sum(o.plannedHrs) from TaskItem o group by to_char(o.taskDate, 'YYYY/MM');
Does it work if the SQL in the exception is executed as a native query? Since this the driver complaining about what looks correct, I would look at the driver/database versions to see if there is a later version that might have a bug that has been fixed.
Best Regards,
Chris -
Error : not a GROUP BY expression
Hi everyone,
Looks like i need some help here.. :) dont know what it means but im getting this message
00979. 00000 - "not a GROUP BY expression"
*Cause:
*Action:
Error at Line: 137 Column: 36
this is the function:
function get_path(materialID in number, materialTypeID in number, inTopFolderID in number default null, inMaterialFolderID in number default null, webMode in number default 1)
return varchar2;
and im using it on my query
,(select material_util.get_path(m.material_id, 8, 1021695, min(mf.IP_MATERIALFOLDERID), 1)
from material m, materialfolder mf
where mf.nfx_link = m.MATERIAL_ID
and m.template_id = t.template_id) as Path
looks like min(mf.IP_MATERIALFOLDERID) is having some issues here.. dont know why..
let me know guys..
thanks..
JA example
with testdata as
select 1 idu, 1 value1, 7 value2, 40 value3 from dual union all
select 2 idu, 2 value1, 8 value2, 45 value3 from dual union all
select 3 idu, 3 value1, 9 value2, 50 value3 from dual union all
select 1 idu, 4 value1, 4 value2, 55 value3 from dual union all
select 2 idu, 5 value1, 5 value2, 60 value3 from dual union all
select 3 idu, 6 value1, 2 value2, 65 value3 from dual
select min(value1), avg(value2), max(value1), sum(value3) from testdata;
MIN(VALUE1) AVG(VALUE2) MAX(VALUE1) SUM(VALUE3)
1 5,83333333333333333333333333333333333333 6 315
Calculate the aggregated functions with all the data of the table.
select idu, min(value1), avg(value2), max(value1), sum(value3) from testdata;
Error SQL: ORA-00937:
00937. 00000 - "not a single-group group function"
Oracle don't know about what values have to calculate the aggrgates functions because there are not aggregated values in the select.
select idu, min(value1), avg(value2), max(value1), sum(value3) from data group by idu;
IDU MIN(VALUE1) AVG(VALUE2) MAX(VALUE1) SUM(VALUE3)
1 1 5,5 4 95
2 2 6,5 5 105
3 3 5,5 6 115
Calculate the aggregated functions in order at idu value. -
Missing expression Error using pivot function
Hi,
When i am running the query:
The query needs to display name and total:
{select *}
{ from (select name,nvl(sal,0) tot from tablea }
{ GROUP BY name,nvl(sal,0) }
{ pivot(SUM(tot) for name in (select ltrim(sys_connect_by_path(''''||name||'''', ','), ',') str}
{from ( select row_number() over(order by name) rn}
{ , name}
{ from tablea}
{where connect_by_isleaf=1}
{start with rn=1}
{connect by rn=prior rn+1);}
When running the above query its giving error:
ORA-00936: missing expression at line select ltrim(sys_connect_by_path
Any help will be needful for meIf you use pivot, you have to hardcode all your values in the FOR IN clause.
SQL> select *
2 from (select ename,nvl(sal,0) tot from emp
3 GROUP BY ename,nvl(sal,0)
4 )
5 pivot(SUM(tot) for ename in ( 'SCOTT' ,'KING') )
6 ;
'SCOTT' 'KING'
3000 5000You can't substitute the literal list of values (in my example ('SCOTT','KING') with a subquery producing similar result.
Only with pivot xml you can put there a subquery, in that case, the result however doesn't have to be in form of comma separated values (like you try to achieve with sys_connect_by_path)
SQL> select *
2 from (select ename,nvl(sal,0) tot from emp
3 GROUP BY ename,nvl(sal,0)
4 )
5 pivot xml (SUM(tot) for ename in ( select ename from emp where ename like 'S%' ) )
6 ;
ENAME_XML
<PivotSet><item><column name = "ENAME">SCOTT</column><column name = "SUM(TOT)">3000</column></item><
item><column name = "ENAME">SMITH</column><column name = "SUM(TOT)">800</column></item></PivotSet>Best regards
Maxim -
GROUP BY with parameter - cause error -ORA-00979: not a GROUP BY expression
I generate a query via PreparedStatement. For example:
SELECT when, value FROM test GROUP BY ?;
PrepState.toString(1, "when");
That causing error: ORA-00979: not a GROUP BY expression
My application using query like:
SELECT to_char(data,1), SUM(vlue) as sum FROM test GROUP BY to_char(data, 2);
PrepState.toString(1, "YYYY-MM");
PrepState.toString(2, "YYYY-MM");Ah. Reproduced in the first chunk of PL/SQL below.
The second chunk is a workaround.
Basically, SQL is parsed by the syntax engine and optimizer to get an execution plan. Then you can have a sequence of "bind, execute, fetch, fetch, fetch..., bind, execute..."
Since you can have multiple binds for a single SQL parse, then the fact that the first set of binds all happen to have the same value doesn't mean the next set will.
The optimizer needs to be 100% sure that the value in the select must always be the same as the value in the group by, so you can't have two separate (and therefore potentially different) bind variable mappings. [Given the right circumstances, the optimizer might do all sorts of tricks, such as using materialized views and function-based indexes.]
Misleadingly, it actually fails on the 'EXECUTE' step of DBMS_SQL rather than the PARSE.
declare
v_sql varchar2(1000) :=
'select to_char(created,:b1), count(*) '||
' from user_objects u '||
' group by to_char(created,:b2) '||
' order by to_char(created,:b3)';
v_fmt varchar2(10) := 'YYYY';
v_cur number;
v_ret_str varchar2(10);
v_ret_num number;
v_ret number;
begin
v_cur := dbms_sql.open_cursor;
dbms_sql.parse(v_cur, v_sql, dbms_sql.native );
dbms_sql.define_column_char (v_cur, 1, v_ret_str, 10);
dbms_sql.define_column (v_cur, 2, v_ret_num);
dbms_sql.bind_variable( v_cur, ':b1', v_fmt );
dbms_sql.bind_variable( v_cur, ':b2', v_fmt );
dbms_sql.bind_variable( v_cur, ':b3', v_fmt );
v_ret := dbms_sql.execute( v_cur );
WHILE ( dbms_sql.fetch_rows(v_cur) > 0 ) LOOP
dbms_sql.column_value_char (v_cur, 1, v_ret_str );
dbms_sql.column_value (v_cur, 2, v_ret_num );
dbms_output.put_line('>'||v_ret_str||':'||v_ret_num);
END LOOP;
end;
declare
v_sql varchar2(1000) :=
'select to_char(created,f.fmt), count(*) '||
' from user_objects u, (select :b1 fmt from dual) f '||
' group by to_char(created,f.fmt) '||
' order by to_char(created,f.fmt)';
v_fmt varchar2(10) := 'YYYY';
v_cur number;
v_ret_str varchar2(10);
v_ret_num number;
v_ret number;
begin
v_cur := dbms_sql.open_cursor;
dbms_sql.parse(v_cur, v_sql, dbms_sql.native );
dbms_sql.define_column_char (v_cur, 1, v_ret_str, 10);
dbms_sql.define_column (v_cur, 2, v_ret_num);
dbms_sql.bind_variable( v_cur, ':b1', v_fmt );
v_ret := dbms_sql.execute( v_cur );
WHILE ( dbms_sql.fetch_rows(v_cur) > 0 ) LOOP
dbms_sql.column_value_char (v_cur, 1, v_ret_str );
dbms_sql.column_value (v_cur, 2, v_ret_num );
dbms_output.put_line('>'||v_ret_str||':'||v_ret_num);
END LOOP;
end;
/ -
GROUP BY and ..not a group by expression ERROR
Hi, I have the following table
===========
STUDENTS
===========
ID NAME TESTDATE MARKS
=== ====== ========= ======
1 JOHN 2007-10-01 10
1 JOHN 2007-10-02 11
1 JOHN 2007-10-02 8
2 MARY 2007-10-01 10
2 MARY 2007-10-02 7
I want to list student with maximum mark he/scored immaterial of the test - date
The following query does it:
SELECT ID, MAX(MARKS)
FROM STUDENTS
GROUP BY ID
RESULT -
ID MAX(MARKS)
=== ===========
1 11
2 10
Now, I want to show the NAME and TESTDATE in the result (remember, only for the max marks)
So I write:
SELECT ID, NAME, TESTDATE, MAX(MARKS)
FROM STUDENTS
GROUP BY ID
XXXXXXX ERROR - not a group by expression - Agreed that TESTDATE & NAME are not in group by expression. I don't want to group by TESTDATE/NAME as it won't yeild the result I am looking for.
What I am looking for is the same result from above with additional fields.
How to get around this problem? any help is highly appreciated.
THANKS IN ADVANCE.Try this (Not tested)
SELECT ID, max(NAME) keep(dense_rank last order by marks) name,
max(testdate) keep(dense_rank last order by marks) testdate,
MAX(MARKS) max_mark
FROM STUDENTS
GROUP BY ID;Or using a subquery...
select id,name,testdate,marks
from
(select id,name,testdate,marks,
row_number() over(partition by id order by marks desc) rn
from students)
where rn = 1; -
ORA-00979: not a GROUP BY expression ORA-01722: invalid number error
This is my follwing code:
select isin,nomenclature,sum(total_balance),c_itd_rddt,c_itd_intrrt from
select distinct instru.c_int_isin isin,
instru.c_int_longdesc nomenclature,
to_char(abs(acpos.acp_totbal),
'999999999999,99,99,990.00')total_balance,
c_itd_rddt,
c_itd_intrrt
from cs_instru_t instru,
cs_instrudetls_t insdtls,
cs_acpos_t acpos
where instru.c_int_instruid = insdtls.c_itd_instruid
and acpos.acp_instruid = instru.c_int_instruid
and acpos.acp_acntnum = 'SG030001'
and instru.c_int_instypid in (1)
and insdtls.c_itd_rddt > ('31-Dec-2010')
and instru.c_int_isin not in
(select spsec.c_ssg_isinno from cs_splsecgrp_t spsec) and acpos.acp_totbal!=0
group by instru.c_int_instruid,
instru.c_int_longdesc,
insdtls.c_itd_rddt,
instru.c_int_insstts,
instru.c_int_isin,
insdtls.c_itd_rddt,
acpos.acp_totbal,c_itd_intrrt
--order by extract(year from c_itd_rddt),c_itd_intrrt
union
select c_srm_prntisin isin,c_int_longdesc nomenclature,to_char(abs(acpos.acp_totbal),
'999999999999,99,99,990.00') total_balance,c_itd_rddt,
c_itd_intrrt from cs_instrudetls_t insdtls,cs_strmap_t map,cs_instru_strips instru,cs_acpos_t acpos
where c_int_instruid=c_srm_prncplinsid
and c_itd_instruid=c_int_instruid
and c_srm_prncplinsid=acp_instruid
and acp_acntnum='SG030001'
)view1
group by isin
I want to group by isin only as only isin is same and the rest of the fields are different.But I want to display all the fields.Please Help
I am getting the following errors:
ORA-00979: not a GROUP BY expression
ORA-01722: invalid numberwat abt the other error ora-01722 not a valid number. How to take sum of total_balance which is to_char
-
Error while using Group By on 2 Querys joined by union
Hello Everyone
I have a situation where in one report i cannot group the data and in another report when i group the data i am unable to view subject area.
I Had a Complex Request from my client , i have to claculate a report based on 2 dimensions i.e i am calculating 2 measures from one dimension and other 3 measures from other dimension and then using UNION to join both the querys , for the same description the data is being displayed in 2 rows , then i i tried to combine both the querys from union and trying to select from those then i am getting the result and the problem is i am unable to access the subject area , its giving "Either you do not have permission to use the subject area within Answers, or the subject area does not exist." Error , i am unable to add prompts to these request
I want the investor Grants Row to be displayed in one Column , I am already using Group by in one of the querys.
Study Cost Approved Committed Earned Paid Balance
Investigator Grants 350,000.00 113,770.78 0.00 0.00 0.00
Investigator Grants 350,000.00 113,770.78 42,403.13 19,905.90 22,497.23
Labs 23,000.00 0.00 0.00 0.00 0.00
Study Drug 47,000.00 0.00 0.00 0.00 0.00
Other 0.00 0.00 0.00 0.00 0.00
Here is my query
SELECT "- Protocol"."Protocol #" saw_0, "- Protocol"."Working Title" saw_1, CURRENT_DATE saw_2, "- Administration"."Display Currency Code" saw_3, "- Protocol"."Managing Country" saw_4, "- Protocol".Country saw_5, "- Protocol"."Country OPS" saw_6, "- Protocol"."EU Country" saw_7, "- Protocol"."GCO Region" saw_8, "- Protocol"."GPB Region" saw_9, "- Administration"."Study Cost" saw_10, SUM (IfNull("- Budget and Payment Facts"."Protocol Cost Line Item Amount - Display CCY",0) BY "- Administration"."Study Cost" ) saw_11, SUM(IfNull("- Budget and Payment Facts"."Committed Amount - Display CCY",0) BY "- Administration"."Study Cost") saw_12, SUM(IfNull("- Budget and Payment Facts"."Actual Amount - Display CCY",0) BY "- Administration"."Study Cost") saw_13, SUM(IfNull("- Budget and Payment Facts"."Amount Paid (SP) - Display CCY",0) BY "- Administration"."Study Cost") saw_14, SUM(IfNull("- Budget and Payment Facts"."Actual Amount - Display CCY",0)-IfNull("- Budget and Payment Facts"."Amount Paid (SP) - Display CCY",0) BY "- Administration"."Study Cost") saw_15, CASE WHEN "- Administration"."Study Cost" = 'Other' THEN 1 END saw_16 FROM "SPECTRUM Reporting" WHERE ("- Administration"."Display Currency Code" = 'USD') AND ("- Protocol"."Protocol #" = 'P31248') UNION SELECT "- Protocol"."Protocol #" saw_0, "- Protocol"."Working Title" saw_1, CURRENT_DATE saw_2, "- Administration". "Display Currency Code" saw_3, "- Protocol"."Managing Country" saw_4, "- Protocol".Country saw_5, "- Protocol"."Country OPS" saw_6, "- Protocol"."EU Country" saw_7, "- Protocol"."GCO Region" saw_8, "- Protocol"."GPB Region" saw_9, "- Administration"."Study Cost" saw_10, IfNull("- Budget and Payment Facts"."Protocol Cost Line Item Amount - Display CCY",0) saw_11, IfNull("- Budget and Payment Facts"."Committed Amount - Display CCY",0) saw_12, 0.00 saw_13, 0.00 saw_14, 0.00 saw_15, CASE WHEN "- Administration"."Study Cost" = 'Other' THEN 1 END saw_16 FROM "SPECTRUM Reporting" WHERE ("- Protocol"."Protocol #" = 'P31248') AND ("- Administration". "Display Currency Code" = 'USD') ORDER BY saw_16 DESC
Any help is appreciated ..!
~SrixHere is the query i used to group the data but i cannot access Answers with this query
SELECT saw_0 saw_0, saw_1 saw_1, saw_2 saw_2, saw_3 saw_3, saw_4 saw_4, saw_5 saw_5, saw_6 saw_6, saw_7 saw_7, saw_8 saw_8, saw_9 saw_9, saw_10 saw_10, SUM(saw_11 BY saw_10) saw_11, SUM(saw_12 BY saw_10 ) saw_12, SUM(saw_13 BY saw_10) saw_13, SUM(saw_14 BY saw_10) saw_14, SUM(saw_15 BY saw_10) saw_15, saw_16 saw_16 FROM (SELECT "- Protocol"."Protocol #" saw_0, "- Protocol"."Working Title" saw_1, CURRENT_DATE saw_2, "- Administration"."Display Currency Code" saw_3, "- Protocol"."Managing Country" saw_4, "- Protocol".Country saw_5, "- Protocol"."Country OPS" saw_6, "- Protocol"."EU Country" saw_7, "- Protocol"."GCO Region" saw_8, "- Protocol"."GPB Region" saw_9, "- Administration"."Study Cost" saw_10, SUM (IfNull("- Budget and Payment Facts"."Protocol Cost Line Item Amount - Display CCY",0) BY "- Administration"."Study Cost" ) saw_11, SUM(IfNull("- Budget and Payment Facts"."Committed Amount - Display CCY",0) BY "- Administration"."Study Cost") saw_12, SUM(IfNull("- Budget and Payment Facts"."Actual Amount - Display CCY",0) BY "- Administration"."Study Cost") saw_13, SUM(IfNull("- Budget and Payment Facts"."Amount Paid (SP) - Display CCY",0) BY "- Administration"."Study Cost") saw_14, SUM(IfNull("- Budget and Payment Facts"."Actual Amount - Display CCY",0)-IfNull("- Budget and Payment Facts"."Amount Paid (SP) - Display CCY",0) BY "- Administration"."Study Cost") saw_15, CASE WHEN "- Administration"."Study Cost" = 'Other' THEN 1 END saw_16 FROM "SPECTRUM Reporting" WHERE ("- Administration"."Display Currency Code" = 'USD') AND ("- Protocol"."Protocol #" = 'P31248') AND ("- Payment"."Payment Number"="- Payment"."Related Payment Request Number")
UNION SELECT "- Protocol"."Protocol #" saw_0, "- Protocol"."Working Title" saw_1, CURRENT_DATE saw_2, "- Administration". "Display Currency Code" saw_3, "- Protocol"."Managing Country" saw_4, "- Protocol".Country saw_5, "- Protocol"."Country OPS" saw_6, "- Protocol"."EU Country" saw_7, "- Protocol"."GCO Region" saw_8, "- Protocol"."GPB Region" saw_9, "- Administration"."Study Cost" saw_10, IfNull("- Budget and Payment Facts"."Protocol Cost Line Item Amount - Display CCY",0) saw_11, IfNull("- Budget and Payment Facts"."Committed Amount - Display CCY",0) saw_12, 0.00 saw_13, 0.00 saw_14, 0.00 saw_15, CASE WHEN "- Administration"."Study Cost" = 'Other' THEN 1 END saw_16 FROM "SPECTRUM Reporting" WHERE ("- Administration"."Display Currency Code" = 'USD') AND ("- Protocol"."Protocol #" = 'P31248')) T GROUP BY saw_0, saw_1, saw_2, saw_3, saw_4, saw_5, saw_6, saw_7, saw_8, saw_9, saw_10 , saw_11, saw_12, saw_13, saw_14, saw_15, saw_16 ORDER BY saw_0, saw_1, saw_2, saw_3, saw_4, saw_5, saw_6 -
Error while using group function
Oracle forms6i
Hai
While i am compile my coding it compile successfully, but when i tried to executes i shows error in group function
my coding is
if (cnt<>0 ) then
select BARCODE,INTIME,OUTTIME into today_bar,today_in,today_out from dail_att where BARCODE= :Barcode
and ATTEND_DATE = :bardate;
update dail_att set outtime = max(:bartime) where barcode= :barcode
and ATTEND_DATE = :bardate;
else
if (cnt2<>0 ) then
select INTIME,OUTTIME into yest_in,yest_out from dail_att where BARCODE= :Barcode
and ATTEND_DATE = :bardate-1;
if(yest_in is not null and yest_out is null) then
update dail_att set outtime =max(:bartime) where barcode= :barcode
and ATTEND_DATE = :bardate-1;
else
insert into dail_att(barcode,intime,attend_date)
values(:barcode,min(:bartime),:bardate);
end if;
else
if :bartime between 0100 and 0630 then
insert into dail_att(barcode,intime,attend_date)
values(:barcode,min(:bartime),:bardate-1);
update dail_att set outtime = max(:bartime) where barcode= :barcode
and ATTEND_DATE = :bardate-1;
else
insert into dail_att(barcode,intime,attend_date)
values(:barcode,:min(bartime),:bardate);
end if;
end if;
end if;
while i am trying to this groupfunction it throws error while i use having tell me how to use group function and where
to use
Regadrs
Srikkanth.MHai sir
I had a table that contain fields
EMPCODE NUMBER
EMPNAME VARCHAR2(25)
BARCODE VARCHAR2(25)
INTIME VARCHAR2(25)
OUTTIME VARCHAR2(25)
INTRTIMEIN VARCHAR2(25)
INTROUTTIME VARCHAR2(25)
PERTIMEIN VARCHAR2(25);
PERTIMEOUT VARCHAR2(25);
ATTEND_DATE DATE ;
Consider that a table with 6 fields ie timein,intrtimein,pertimein,pertimeout,intrtimeout,timeout
I have generating a attendance table and a table contain 6 various times for an employees and we need to arrange it in order
0815,0816,1230,1250,1645,1646
If 0815 is the starting time then timein ie mintime
0816 stored to be in intrtime
then1250 then it stored in pertimein
then 1230 then it stored in pertimeout
then 1645 stored in intrtimeout
then 1646 stored in timeout
I tried with max and min function but its not working properly pls tell me some solutions
Thanks & Regards
Srikkanth.M -
Hi ,
I am using Oracle report 10G
And trying to create report with dynamic table
SELECT &COL1, &COL2
FROM &TAB
If I put this on data model it gives below error
ORA-00936: missing expression
==> from
Can anybody advise to solve this issue.
Regards,
BrajeshLook in the Reports Builder Help:
If you want to use lexical references in your SELECT clause, you should create a separate lexical reference for each column you will substitute. In addition, you should assign an alias to each lexical reference.
Does adding the column alias solve the problem? -
Getting "ORA-00979: not a GROUP BY expression" error in Inline query
Hello all,
The following query when run in SCOTT user gives "ORA-00979: not a GROUP BY expression" error.
If I remove the TRUNC function from the outer query's group by clause, then it fetches
(My actual query is something similar to the following query. I have given emp, dept tables for convenience's sake)
select e.empno,e.ename, AVG(e.SAL), trunc(e.hiredate),
(select sum(sal) from emp
where hiredate = e.hiredate) salary
from emp e
group by e.DEPTNO,e.EMPNO,e.ENAME, trunc(e.hiredate)
Pls suggest how this error can be avoided.
Regards,
SamWhy not this?
satyaki>
satyaki>select * from v$version;
BANNER
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
PL/SQL Release 10.2.0.1.0 - Production
CORE 10.2.0.1.0 Production
TNS for Linux: Version 10.2.0.1.0 - Production
NLSRTL Version 10.2.0.1.0 - Production
Elapsed: 00:00:00.02
satyaki>
satyaki>
satyaki>select e.empno,
2 e.ename,
3 AVG(e.SAL),
4 trunc(e.hiredate),
5 (
6 select sum(sal)
7 from emp
8 where hiredate = e.hiredate
9 ) salary
10 from emp e
11 group by e.DEPTNO,
12 e.EMPNO,
13 e.ENAME,
14 e.hiredate;
EMPNO ENAME AVG(E.SAL) TRUNC(E.H SALARY
7934 MILLER 1887.6 23-JAN-82 5583.6
7698 Glen 1848 23-JAN-82 5583.6
7788 SCOTT 598.95 19-APR-87 598.95
7900 JAMES 1379.4 03-DEC-81 6650.16
7521 WARD 226.88 22-FEB-81 226.88
7599 BILLY 4500 10-JUN-09 4500
2222 sp 1200 14-SEP-09 1200
7902 FORD 5270.76 03-DEC-81 6650.16
7566 Smith 1848 23-JAN-82 5583.6
7654 MARTIN 1815 28-SEP-81 1815
7839 KING 7260 17-NOV-81 7260
EMPNO ENAME AVG(E.SAL) TRUNC(E.H SALARY
7844 TURNER 2178 08-SEP-81 2178
7876 ADAMS 159.72 23-MAY-87 159.72
13 rows selected.
Elapsed: 00:00:00.03
satyaki>Regards.
Satyaki De. -
TBB1-Execute postings occurs an error *Ledger group 0L may not be used*
Hi everybody,
While trying to execute postings from a commercial paper occurs the following error
Ledger group 0L may not be used
Message no. FAGL_LEDGER_CUST102
Diagnosis
Ledger group &1 is assigned to another application.
I suspect that this is somehow related to Funds management influence, but I can not find the solution,
I really need to overcome this problem so i'll appreciate any help,
Thanks in advance,
DanielHi Prasad,
We created ledger groups in costumizing this issue was solved.
Thank you very much your help.
Regards,
Daniel -
Error ORA-00979: not a GROUP BY expression
I have to run a query to list the Product_code, stock_level, and the total quantity ordered
The tables are as follows:
PRODUCT:
PRODUCTCODE PRODDESCRIPTION PRICE STOCKLEVEL
p1 carpet 40 10000
p2 tile 20 100000
p3 pergo 50 50000
PRODLINE:
ORDERNUMBER PRODCODE QUANTITY
o1 p1 1000
o1 p2 500
o2 p3 200
o3 p1 600
o3 p3 100
o4 p2 1000
o5 p2 800
Here is my SQL Statement:
SELECT pl.PRODCODE, SUM(pl.QUANTITY), pr.STOCKLEVEL
FROM PRODLINE pl, PRODUCT pr
WHERE pl.PRODCODE=pr.PRODUCTCODE
GROUP BY pl.PRODCODE;
RESULT:
ORA-00979: not a GROUP BY expression
Can someone please assist?Welconme to the forum!
895231 wrote:
... Here is my SQL Statement:
SELECT pl.PRODCODE, SUM(pl.QUANTITY), pr.STOCKLEVEL
FROM PRODLINE pl, PRODUCT pr
WHERE pl.PRODCODE=pr.PRODUCTCODE
GROUP BY pl.PRODCODE;
RESULT:
ORA-00979: not a GROUP BY expression
Can someone please assist?Remember the ABC's of GROUP BY:
When you use a GROUP BY clause and/or an aggregate fucntion, then everything in the SELECT clause must be:
(A) an <b>A</b>ggregate function,
(B) one of the "group <b>B</b>y" expressions,
(C) a <b>C</b>onstant, or
(D) something that <b>D</b>epends entirely on the above. (For example, if you "GROUP BY TRUNC(dt)", you can SELECT "TO_CHAR (TRUNC(dt), 'Mon-DD')").
In your query, pr.stocklevel is none of the above.
The previous respondent show how you can make it one of the "group <b>B</b>y" expressions, which is noramlly how you would handle this situation.
Alternatively, you could make it an <b>A</b>ggregate function, like this:
SELECT pl.PRODCODE
, SUM (pl.QUANTITY) AS total_quantity
, MIN (pr.STOCKLEVEL) AS stokclevel
FROM PRODLINE pl
, PRODUCT pr
WHERE pl.PRODCODE = pr.PRODUCTCODE
GROUP BY pl.PRODCODE; -
Nesting error when re-using groups
JDev 11.1.1.4, JHS 11.1.1.3.35
I have two related objects, ObjectA and ObjectB. In my app I need a primary form for ObjectA, with ObjectB on a detail group, plus a primary form for ObjectB with ObjectA as a detail group. I create re-usable groups, GroupA and GroupB. When I re-use GroupB as a detail group on GroupA, no problems, but then when I also re-use GroupA as a detail group for GroupB I get an error:
Nested BindingContainer of this type [GroupBPageDef] is already included in this parent BindingContainer:data.app_UIShellPageDef.mainRegion.[GroupAPageDef]_WEB_INF_adfc_config_[GroupA]_xml_[GroupA]TaskFlow.[GroupB]TaskFlowBinding.[GroupBPageDef]_WEB_INF_adfc_config_[GroupB]_xml_[GroupB]TaskFlow.[GroupA]TaskFlowBinding
Am I setting it up wrong? Or is it just not possible to re-use in both directions like that?I hit the same error last week in JDeveloper 11.1.2 in an app without JHeadstart. This seems to be a limitation of ADF, not related to JHeadstart.
Please raise this issue on the JDeveloper forum, or even better with Customer support, with a simple testcase, because it limits the reuse options for taskflows.
Steven Davelaar,
Jheadstart team.
Maybe you are looking for
-
SCCM 2012 R2 Configuration Manager Client Package - stuck "In Progress"
Hi Team; I’m having 2 issues with SCCM 2012 R2: Issue 1: I'm having a strange issue with the default XXX00002 package - "Configuration Manager Client Package", it will not deploy to the Secondary Site DP. The console is saying "In Progress" - below i
-
When comparing scripts and smartforms which is better
hi can you please help out the advantages and disadvantages of scripts and smartforms
-
File Content Conversion - nested structures
In the above bolded message ... 2 Records are repeating for multiple times.. i know how to do.. if its repeats like below.. i know how to do.. Record1 Record1 Record1 Record1 Record1 Record1 Record1 Record2 Record2 Record2 Record2 Record2 Record
-
WiFi says I need a password but there isn't one when I connect with my phone
The title says it all. I'm trying to connect to McDonald's public WiFi and when I connect with my phone, it works normally, but when I try to connect with my Mac, it says that either the connection has timed out or I entered the wrong password. I'm r
-
Can I use standard RF Menu LM00 for IM Managed facility (No WM at all).
Can I use standard RF Menu LM00 for perfomring IM goods movement in IM Managed facility (No WM at all).