ROLLUP & CUBE GROUP FUNCTION
can anybody explain the functionality of ROLLUP and CUBE functions in oracle9i
Lets do us all a favor and use current docs (that is < 11g which is still too new for most)
http://www.oracle.com/pls/db102/homepage
Similar Messages
-
Hi,
Can anyone help me to get the following output with site-sub-total and grand-total within the one possible query: (I know it's possible either with Analytic function or new Group By Rollup/Cube functionality but do not know how to use them).
QUERY:
SELECT /*+ index(con con_start_end_i) */
con.id Contract,
con.property_id Property,
con.site_code,
con.ctyp_code,
con.crea_code,
con.purchase_price Puarchase_Amt,
con.commission_amount Comm_Amt,
con.start_date,
con.target_exchange_date,
con.target_completion_date,
con.empl_id,
con.sold_by
FROM
t_contracts con
WHERE
EXISTS ( SELECT 1 FROM t_employee_sites es WHERE es.emp_login_name = USER and es.site_code = con.site_code ) AND
con.empl_id LIKE '%' AND
NVL(con.sold_by,-1) = NVL(NULL, nvl(con.sold_by,-1)) AND
con.ctyp_code = 'SALE' AND
INSTR('WITHDRAW,PULL_OUT,', NVL(con.crea_code,'*')) = 0 AND
con.deleted IS NULL AND
(con.completed_date IS NULL OR con.completed_date > TO_DATE('13/06/2005', 'dd/mm/rrrr')) AND
con.start_date BETWEEN TO_DATE('13/06/2005', 'dd/mm/rrrr') and TRUNC(SYSDATE)
ORDER BY
con.site_code;
Sample Output:
Please find the following sample output:
Contract, Property, Crea_Code, Purchase_Amt, Comm_Amt, Start_Date, Sold_By
Site: <Site_Code1>
xxxx xxxx xxxx 9,999,999.99 9,999,999.99 dd/mm/yyyy xx
xxxx xxxx xxxx 9,999,999.99 9,999,999.99 dd/mm/yyyy xx
Total for Site: <Site_Code1> <Site1_Pur> <Site1_Comm>
No of Property: <Site1_Count>
Site: <Site_Code2>
xxxx xxxx xxxx 9,999,999.99 9,999,999.99 dd/mm/yyyy xx
xxxx xxxx xxxx 9,999,999.99 9,999,999.99 dd/mm/yyyy xx
Total for Site: <Site_Code2> <Site2_Pur> <Site2_Comm>
No of Property: <Site2_Count>
Total: <Tot_Pur> <Tot_Comm>
Total Property: <Tot_Count>
Your help would appreciate to sort this out asap....
Kind Regards,
B Tanna
London
UKHi Riedelme,
Thanks for your reply. Further to your reply I go through Group By functionality. I tried the different ways and found the solution. I have to use
GROUP BY GROUPING SETS(con.site_code, (con.site_code, con.id, con.property_id, con.ctyp_code, con.crea_code, con.start_date, con.target_exchange_date, con.target_completion_date, con.empl_id, con.sold_by), ())But now my worry is what happens if number of column grows, say, 35. There should be some way of writing good query. Would it be possible using Analytic Function.
Experts please respond.. -
<SQL> Connect Scott/Tiger
Connected.
<SQL> Select Deptno,
2 Decode(Ename,Null,'T O T A L',Ename),
3 SUM(Sal)
4 From Emp
5 Group By ROLLUP(Deptno,Ename);
DEPTNO DECODE(ENA SUM(SAL)
10 AWAIS 5000
10 CLARK 2450
10 MILLER 1300
10 T O T A L 8750
20 23132121 1000
20 ADAMS 1100
20 FORD 3000
20 JONES 2975
20 SCOTT 3000
20 SMITH 800
20 T O T A L 11875
30 ALLEN 1600
30 BLAKE 2850
30 JAMES 950
30 MARTIN 1250
30 TURNER 1500
30 WARD 1250
30 T O T A L 9400
T O T A L 30025
19 rows selected.
RollUp Functionality is Perfect.
But what is this ?
SQL> Select Deptno,
2 Decode(Ename,Null,'T O T A L',Ename),
3 SUM(Sal)
4 From Emp
5 Group By CUBE(Deptno,Ename);
DEPTNO DECODE(ENA SUM(SAL)
10 AWAIS 5000
10 CLARK 2450
10 MILLER 1300
10 T O T A L 8750
20 23132121 1000
20 ADAMS 1100
20 FORD 3000
20 JONES 2975
20 SCOTT 3000
20 SMITH 800
20 T O T A L 11875
30 ALLEN 1600
30 BLAKE 2850
30 JAMES 950
30 MARTIN 1250
30 TURNER 1500
30 WARD 1250
30 T O T A L 9400
23132121 1000
ADAMS 1100
ALLEN 1600
DEPTNO DECODE(ENA SUM(SAL)
AWAIS 5000
BLAKE 2850
CLARK 2450
FORD 3000
JAMES 950
JONES 2975
MARTIN 1250
MILLER 1300
SCOTT 3000
SMITH 800
TURNER 1500
WARD 1250
T O T A L 30025
34 rows selected.
Cube is Selecting 34 Rows, Why ?
I am not understanding the functionalilty of Cube.
Can any one define it ?
Thanks in Advance...Hi,
With cube, you create subtotals in different dimension. Your example does not make sense for cube, since ename is unique for all departments.
Look at this. Also note the "GROUPING" function, which distinguish pure null values and null because of grouping (giving 1).
Kind regards
Laurent Schneider
OCM-DBA
select decode(grouping(JOB), 1, 'T O T A L', job) JOB,
decode(grouping(DNAME), 1, 'T O T A L', dname) DNAME,
sum(nvl(sal,0))
from emp natural full outer join dept
group by cube(job,dname)
order by 1 nulls first, 2 nulls first;
JOB DNAME SUM(NVL(SAL,0))
OPERATIONS 0
T O T A L 0
ANALYST RESEARCH 6000
ANALYST T O T A L 6000
CLERK ACCOUNTING 1300
CLERK RESEARCH 1900
CLERK SALES 950
CLERK T O T A L 4150
MANAGER ACCOUNTING 2450
MANAGER RESEARCH 2975
MANAGER SALES 2850
MANAGER T O T A L 8275
PRESIDENT ACCOUNTING 5000
PRESIDENT T O T A L 5000
SALESMAN SALES 5600
SALESMAN T O T A L 5600
T O T A L ACCOUNTING 8750
T O T A L OPERATIONS 0
T O T A L RESEARCH 10875
T O T A L SALES 9400
T O T A L T O T A L 29025 -
Grouping Function usage in SQL
All,
How does grouping function work, does it also depends on the sequence of columns used in group by rollup
select deptno,job, group_id(), sum(sal), grouping(deptno) , grouping(job)
from emp
group by rollup (deptno, job)
If the query is run by "rollup(job,deptno)" grouping (deptno) returns 1 where as if "rollup(deptno,job)" grouping (deptno) returns 0.
Does the column sequence in group by rollup decides the returning of grouping(deptno) function. I feel to have some misunderstanding of the way its said in ORACLE documentation. We referred to the below link for our understanding.
http://download.oracle.com/docs/cd/E11882_01/server.112/e17118/functions071.htm
Request the PRO's to discuss and clarify on this.Hi,
ramarun wrote:
All,
How does grouping function work, GROUPING (x) returns 1 if the current row represents a superaggregate of x, and 0 otherwise. In other words, if GROUPING (x) is 0, then the row represents a single value of x. If GROUPING (x) is 1, then the row represents a total of all values of x.
For example the query you posted may produce results like this:
` DEPTNO JOB GROUP_ID() SUM(SAL) GROUPING(DEPTNO) GROUPING(JOB)
20 ANALYST 0 6000 0 0
ANALYST 0 6000 1 0
10 CLERK 0 1300 0 0
20 CLERK 0 1900 0 0
30 CLERK 0 950 0 0
CLERK 0 4150 1 0
10 MANAGER 0 2450 0 0
20 MANAGER 0 2975 0 0
30 MANAGER 0 2850 0 0
MANAGER 0 8275 1 0
10 PRESIDENT 0 5000 0 0
PRESIDENT 0 5000 1 0
30 SALESMAN 0 5600 0 0
SALESMAN 0 5600 1 0
0 29025 1 1Look at the last three rows. On this row
` DEPTNO JOB GROUP_ID() SUM(SAL) GROUPING(DEPTNO) GROUPING(JOB)
30 SALESMAN 0 5600 0 0GROUPING (deptno) is 0; so the row represents only deptno=30.
GROUPINT (job) is 0, so the row represents only job='SALESMAN'.
SUM (sal) is 5600, so the total salary of all salesmen in department 30 is 5600.
Now look at this row:
` DEPTNO JOB GROUP_ID() SUM(SAL) GROUPING(DEPTNO) GROUPING(JOB)
SALESMAN 0 5600 1 0GROUPING (deptno) is 1; so the row does not represent any one deptno; it is a superaggregate of all deptnos. Notice that the deptno column is NULL, even though there are no rows in the table where deptno is NULL.
GROUPING (job) is 0, so the row represents only job='SALESMAN'.
SUM (sal) is 5600, so the total salary of all salesmen in any department is 5600. (As it happens, all the salesmen are in department 30, so this sum is the same as on the previous row.)
Now look at the last row:
` DEPTNO JOB GROUP_ID() SUM(SAL) GROUPING(DEPTNO) GROUPING(JOB)
0 29025 1 1GROUPING (deptno) is 1; so the row does not represent any one deptno; it is a superaggregate of all deptnos. Notic that both deptno and job are both NULL on this row of output, even though neither column is ever NULL in the table.
GROUPING (job) is 0, so the row represents only job='SALESMAN'.
SUM (sal) is 5600, so the total salary of people with any job and any department is 29025.
does it also depends on the sequence of columns used in group by rollup Excellent question! Try it an see. Change the order or columns in the GROUP BY clause and see. If you get different results, then the order does matter.
select deptno,job, group_id(), sum(sal), grouping(deptno) , grouping(job)
from emp
group by rollup (deptno, job) If the query is run by "rollup(job,deptno)" grouping (deptno) returns 1 where as if "rollup(deptno,job)" grouping (deptno) returns 0. You get different results; therefore the order does matter.
Does the column sequence in group by rollup decides the returning of grouping(deptno) function...Yes.
"GROUP BY ROLLUP (deptno, job)" means a superaggregate row for each value of job, representing all deptnos, will be formed. That is, you will get one row representing all analysts; another row representing all clerks, another row representing all managers, and so on. This will be similar to the results that you would get if you never mentioned the first expression in the ROLLUP list, that is, deptno. You will not get a superaggregate row representing any one deptno, say, 10.
"GROUP BY ROLLUP (job, deptno)" means a superaggregate row for each value of deptno, representing all jobs, will be formed. That is, you will get one row representing all anlysts; another row representing deprtment 10, another row representing department 20, and so on. This will be similar to the results that you would get if you never mentioned the first expression in the ROLLUP list, that is, job. You will not get a superaggregate row representing any one job, say, 'ANALYST'. -
JDBC 8.1.6.0.1 Bug with grouping function
Hi,
I found a bug in the JDBC 8.1.6.0.1 driver, concerning the new grouping functionality of Oracle 8.1.6. Look at the following code fragment:
String cSelect = "SELECT DACO_VU_NAME AS DIM1, ' ' AS DIM2, TO_CHAR(DACO_VERKAUFSDATUM,'yyyymm') AS DIM_DATE, GROUPING(DACO_VU_NAME) AS DIM1GROUP, GROUPING(' ') AS DIM2GROUP, GROUPING(TO_CHAR(DACO_VERKAUFSDATUM,'yyyymm')) AS DIM_DATEGROUP, sum(DACO_BRUTTOBETRAG_TX) AS VALUE FROM DATENCONTAINER GROUP BY CUBE (DACO_VU_NAME, '-', TO_CHAR(DACO_VERKAUFSDATUM,'yyyymm') ) ORDER BY 1,2,3";
try {
System.out.println("SELECT: " + cSelect);
Statement stmt = conn.createStatement();
ResultSet rset = stmt.executeQuery(cSelect);
while (rset.next()) {
String cTest1 = rset.getString("DIM1");
String cTest2 = rset.getString("DIM2");
String cTest3 = rset.getString("DIM_DATE");
String cChar1 = rset.getString("DIM1GROUP");
String cChar2 = rset.getString("DIM2GROUP");
String cChar3 = rset.getString("DIM_DATEGROUP");
System.out.println(cTest1 + "\t" + cTest2 + "\t" + cTest3 + "\t" + cChar1 + "\t" + cChar2 + "\t" + cChar3);
}When I compile this with the mentioned JDBC version and run it with java 1.2.2 (JDeveloper 3.1), i get the following output:
Ahrend GmbH & Co. KG 200003 0 0 0
Ahrend GmbH & Co. KG 200003 1 0 0
Ahrend GmbH & Co. KG 200004 0 0 0
Ahrend GmbH & Co. KG 200004 1 0 0
Ahrend GmbH & Co. KG null 0 0 1
Ahrend GmbH & Co. KG null 1 0 1
null 200003 0 1 0
null 200003 1 1 0
null 200004 0 1 0
null 200004 1 1 0
null null 0 1 1
null null 1 1 1As you can see, the grouping columns are mixed up. In this example, everywhere a normal row shows a "null" value, a corresponding grouping row should show a "1", but as you can see, for the last 6 rows, the ones are not in the first, but in the second grouping row.
When I compile the example with the Oracle 8.1.5 JDBC driver, I get the following, correct, output:
Ahrend GmbH & Co. KG 200003 0 0 0
Ahrend GmbH & Co. KG 200004 0 0 0
Ahrend GmbH & Co. KG null 0 0 1
Ahrend GmbH & Co. KG 200003 0 1 0
Ahrend GmbH & Co. KG 200004 0 1 0
Ahrend GmbH & Co. KG null 0 1 1
null 200003 1 0 0
null 200004 1 0 0
null null 1 0 1
null 200003 1 1 0
null 200004 1 1 0
null null 1 1 1The special thing about this example is, that I use a constant row for grouping (row 2). If you use a normal database row, everything works fine with 8.1.6.0.1, but nevertheless, this should be a bug.
Any comments on this are highly appreciated, since I need the JDK 1.2 for the application and I didn't find a working Oracle 1.2 JDBC version.
Thanks,
Thorsten.Patches can be obtained from an Oracle Support Services technical analyst.
null -
could you please let me know groupping functions in BI7 ?'
what is it's significance and how it works in BI7 ?
Thanks
RegardsHi,
What Grouping functions you are referring to??
If It is about BC Activation then Same as the 3.x version.
Hope you know how these works
Data Flow Before --- if you are try to activate a cube all data flow before the cube like transformations, DSO, DS, Info objects will be activated
Data Flow After -- Cube -- Query -- Work Book along with Roles
Data Flow before After -- Picks entire Flow from Info Objects to Work Books.
Only Necessary Objects -- Advisable and most used -- you can activate all your required and necessary objects
Hope it is clear and helpful. -
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 -
How to use group function in insert or update
Hai All
How can we use group function in insert or update statement
I am generating an attendance so i have different set of timing for example
0800,1200,1230, 1700 and i need to insert into these data into table with min value to intime and max value to
outtime and othere to inertval time in or out
Pls tell me with some example
For example
For INSERT
insert into T2 (barcode,empcode,intime,attend_date)
values(r2.cardn,r2.enpno,MIN(r2.ptime),r2.pdate);
For UPDATE
update dail_att set outtime= MAX(r2.ptime) where empcode=r2.enpno and barcode=r2.cardn and
attend_date=r2.pdate;
Here instead of where i need to use having so pls tell how to use
Thanks & Regards
Srikkanth.MHai Man
R2 is not a table name its a record
Let me explain clearly
I have to generate daily attendance for lot of employees So i have two table t1 and t2
T1 consist of three column empno,date,time
T2 consist of empno,name,date,intime,outtime,intrin,introut
So now i need to give the T1 Min value Of time to T2 Intime and T1 Max value of Time to T2 Outtime fields so there so many records while i am using
max(time) it gives the max value of all so i seperated by group function so now i have an error in subquery ie it is an single row subquery so i need to use multiple row subquery how i can use multiple row subquery in update statement
Thanks In Advance
Srikkanth.M -
PL/SQL equivalent of T-SQL - "group function is not allowed here"
Hi all, hope someone can give me a hand as I'm pretty stuck! I have been trying to convert some MS SQL Server T-SQL statements into Oracle PL/SQL and am stuck on the below one:
SELECT
CA.AssessmentID,
(SELECT ProductName + ISNULL(' - ' + PrincipalBenefit,'')
FROM rptPolicySnapshot WHERE PolicyID = MAX(CA.PolicyID)
AND SnapshotID = 1),
MAX(CA.PolicyID)
FROM rptClaimInvoiceLineSnapshot CIL
INNER JOIN rptClaimAssessmentSnapshot CA
ON CIL.AssessmentID = CA.AssessmentID
AND CIL.SnapshotID = CA.SnapshotID
WHERE CIL.SnapshotID = 1
GROUP BY CA.AssessmentID
This works fine in MSSQL but returns the below error in Oracle:
'ORA-00934: group function is not allowed here'
If I take out the subquery the query works fine.
Any ideas as to the syntax? I am new to Oracle so not sure as to how I should go about writing this.
Thanks in advance!
LeoWITH x AS (SELECT ca.assessmentid,
MAX (ca.policyid) policy_id
FROM rptclaiminvoicelinesnapshot cil
INNER JOIN rptclaimassessmentsnapshot ca
ON cil.assessmentid = ca.assessmentid
AND cil.snapshotid = ca.snapshotid
WHERE cil.snapshotid = 1
GROUP BY ca.assessmentid
SELECT x.assessment_id,
x.policy_id,
productname + decode(principalbenefit,null,null,' - ' || principalbenefit ) prodname
FROM rptpolicysnapshot, x
WHERE policyid = x.policy_id
AND snapshotid = 1I think that's in the neighbourhood. -
Is there a way to create a group function?
I want to create a group function like max,sum,count for a
pl/sgl function. This group function will be something like max
(let's call it max2) but it will return the second highest value
of a group.
Any ideas anyone?Since you might not completely understand what i mean i give you
this example:
the ranktest table is:
A B C
a b 1
a b 1
a b 5
a b 12
a b 7
b c 1
b c 3
b c 2
b c 4
b c 8
c d 4
c d 3
c d 6
c d 1
c d 2
c d 12
c d 7
c d 3
a b 5
c d 12
SELECT A,B,C
FROM (
SELECT A,B,C, dense_rank() over (
PARTITION BY A,B
ORDER BY C desc) AS sorted_c
FROM ranktest a)
WHERE sorted_c = 2
-- this way we get the c column to have the 2nd highest value
-- for each set of A and B
--RESULT
a b 7
b c 4
c d 7
SELECT a.A,a.B, sum(a.C), count(a.C)
FROM ranktest a
GROUP BY a.A,a.B
-- this way we get the group functions to work on two of the
-- columns
--RESULT
a b 31 6
b c 18 5
c d 50 9
The result that i want is
a b 31 6 7
b c 18 5 4
c d 50 9 7
My question is can this be done in a single select statement. I
know it can be done with an intermediate step (of the creation
of a temp table).
Plus i would like to ask the experts, would a single select
statement be more efficient?
NOTE: the tables and data are just test data. The real tables
and data and the select query are different. The real ranktable
has about 1 million records. That's why i am worried about
efficiency. -
How to create a user_defined grouping function?
I need to create a user_defined function and use it in my sql statement.
I know the user_defined function can be used anywhere the build-in function can be used.In oracle,there are grouping functions.
How can I create a user_defined grouping function and I can use it in my sql statement.Hi, can you explain exactly what you are trying to achieve:
SQL> create or replace function my_func return number as
2 begin
3 return 5;
4 end;
5 /
Function created.
SQL> select deptno,my_func(),max(sal)
2 from emp
3 group by deptno,my_func()
4 /
DEPTNO MY_FUNC() MAX(SAL)
10 5 5000
20 5 3000
30 5 2850 -
ORA-00978 without group function
I've experienced a strange problem with oracle 11g.
I've retrieved the oracle exception ORA-00978 even if there was no group function in my query.
I supposed was a problem in the optimizer so I rebuild the tables statistics, after that the query was execute successfully.
Does anyone has an idea what the problem is?
Is possible that a bug exists in the 11g optimizer?
My oracle version is:
Oracle Database 11g Enterprise Edition 11.1.0.6.0 64bit Production
the query i tried is:
SELECT *
FROM TBCALENDAR Cal,
VWCALENDARACTIVITY CA,
VWSE R,
TBSCHEDULERPARTITION P,
TBREGION REG,
TBRESOURCE RES ,
TBZIPCITY z
WHERE Res.id=Cal.RESOURCE_ID
AND R.RESOURCE_ID=RES.ID
AND Cal.ACTIVITY_ID=CA.ID
AND CA.SCHEDULING=1
AND Cal.SCHEDPARTITION_ID IN
(select item.PARTITION_ID
from tbidcprofile prof,
tbidcpartitem part,
tbschedpartitem item
where prof.USERPROFILE_ID=4
and prof.IDCPARTITION_ID=part.PARTITION_ID
and part.BUSINESSUNIT_ID=item.BUSINESSUNIT_ID
and part.REGION_ID=item.REGION_ID )
AND TRUNC(Cal.START_DT)=trunc(sysdate)
AND P.ID=Cal.SCHEDPARTITION_ID
AND REG.ID(+)=Cal.WORKREGION_ID
AND Z.GEOLOCATION_ID(+)=Cal.HOMEGEOLOC_ID;
VWCALENDARACTIVITY and VWSE are two views, but I can select from them without any problem.
I've also tried to remove one view at a time an the error occurs only when the query uses both view at the same time.
Thanks
Renzouser479513 wrote:
VWCALENDARACTIVITY and VWSE are two views, but I can select from them without any problem.
I've also tried to remove one view at a time an the error occurs only when the query uses both view at the same time.
What are the views definition ?
Nicolas. -
How to create a grouping function
How to create a grouping function ?? For example, can I create a function:myavg and I can use it like :
select col_a, col_b, myavg(col_c)
from table_a
group by col_a, col_b
Thanks in advance !!
nullI don't think that you can create a grouping function in Oracle, but you can create a function and use it in Select statments.
null -
Hello all,
How can I use a nested group function in a select statement?
For example: select sum(count(id), column a, column b from table_name group by???
Thanks in advance!select sum(CNT) column_a, column_b
from (select count(id), column_a, column_b from table_name
group by column_a, column_b)
group by column_a, column_b -
Not a single-group group function very urgent
HI,
select sum(avg(wait_to))+sum(avg(idle))+sum(avg(users))+sum(avg(system)) from system_cpu
where hostid='DSCP02469' group by cpuid
this query is working
but i want cpuid group to be displayed
so i wrote query like this.
select cpuid,sum(avg(wait_to))+sum(avg(idle))+sum(avg(users))+sum(avg(system)) from system_cpu
where hOstid=' ' group by cpuid it is throwing a error
not a single-group group function.
how can get sum of avg of colums,column based on some coloum
group by column
id,sum(avg( )) i have to get
please give me solution.
send me mail to [email protected]hi,
thanku for immediate reply but
if i do that
select cpuid, a+b+c+d total_value from (select cpuid,
sum(avg(wait_to)) a, sum(avg(idle)) b,sum(avg(users)) c,sum(avg(system)) d
from system_cpu where hostid='DSCP02469' group by cpuid)
SQL> /
select cpuid, a+b+c+d total_value from (select cpuid,
ERROR at line 1:
ORA-00937: not a single-group group functionelse
select cpuid, a+b+c+d total_value from (select
sum(avg(wait_to)) a, sum(avg(idle)) b,sum(avg(users)) c,sum(avg(system)) d
from system_cpu where hostid='DSCP02469' group by cpuid)
SQL> /
select cpuid, a+b+c+d total_value from (select
ERROR at line 1:
ORA-00904: "CPUID": invalid identifier2)
can we use select in select case
can we use select sal, case when sal then select * from emp like this
with regards
shannu sarma
Maybe you are looking for
-
Unable to Schedule the Report with a user with Author Role.
Hi, I tried to Schedule the Report using weblogic user(which has admin role) it worked perfectly. But when i try to login using User(which has author role) and when i try to schedule a report i am getting the following error. It is clustered Environm
-
Flash Player X installed but not working (6MB file instead of 15MB)
I installed version 11 Active X 11.5.502.135 BUT it is only 6MB file and should be 15MB so it does not play videos. It did not hang up during installation (download timeout) but went right ahead and installed but it cannot be the full deal. I have u
-
Importing images from ipod into iPhoto
I installed the iPhoto 9.2 update as part of the OSX10.7.2 and am now when I try import my pictures that are stored on my iPod Touch only my Mac shows up. The iPod used to show so I could import the images stored on it, but now that option doesn't ex
-
Hi, i have occasionally problems using preview to display PDFs. For example this one: http://www.ldc.upenn.edu/acl/W/W03/W03-1604.pdf In preview the documents content is mostly destroyed, yet some figures survived. Of course, my first tough was that
-
HasPermission and UME Web Service Access
Hi! Does anyone know how to call hasPermission from a web service? I have a web service running out on the WebAS, and I am trying to use an IUser from the Role Factory to call hasPermission(...); however it always returns false. Is it because there i