niXforums Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   PreferencesPreferences   Log in to check your private messagesLog in to check your private messages   Log inLog in 
·  nixdoc.net ·  man pages ·  Linux HOWTOs ·  FreeBSD Tips ·  Forums
navigation Forum index » Databases » Oracle » Tools
Compute in Oracle
Post new topic   Reply to topic Page 1 of 2 [28 Posts] View previous topic :: View next topic
Goto page:  1, 2 Next
Author Message
DA Morgan
*nix forums Guru


Joined: 06 Mar 2005
Posts: 1042

PostPosted: Fri Feb 25, 2005 12:59 am    Post subject: Re: Compute in Oracle Reply with quote

maya wrote:
Quote:
Frank,

Lets say I have a variable "teacheraverage"
I would say,

BTITLE column xxx teacheraverage
and then for breaks ?

break on ..[ whats the format] here to display the variable under each
teacher's...

http://tahiti.oracle.com

We are not hear to do your work for you. Please read the manual.
--
Daniel A. Morgan
University of Washington
damorgan@x.washington.edu
(replace 'x' with 'u' to respond)
Back to top
Frank van Bortel
*nix forums Guru


Joined: 19 Apr 2005
Posts: 804

PostPosted: Thu Feb 24, 2005 7:31 pm    Post subject: Re: Compute in Oracle Reply with quote

Frank van Bortel wrote:
Quote:
maya wrote:

Frank,

Lets say I have a variable "teacheraverage"
I would say,

BTITLE column xxx teacheraverage
and then for breaks ?

break on ..[ whats the format] here to display the variable under each
teacher's...

break on (whatever you want the teacheraverage to follow on) skip page

and it *is* all in the SQL*Plus User's Guide and reference


--
Regards,
Frank van Bortel
Back to top
Frank van Bortel
*nix forums Guru


Joined: 19 Apr 2005
Posts: 804

PostPosted: Thu Feb 24, 2005 7:30 pm    Post subject: Re: Compute in Oracle Reply with quote

maya wrote:
Quote:
Frank,

Lets say I have a variable "teacheraverage"
I would say,

BTITLE column xxx teacheraverage
and then for breaks ?

break on ..[ whats the format] here to display the variable under each
teacher's...

break on (whatever you want the teacheraverage to follow on) skip page


--
Regards,
Frank van Bortel
Back to top
maya
*nix forums beginner


Joined: 16 Feb 2005
Posts: 25

PostPosted: Thu Feb 24, 2005 5:53 pm    Post subject: Re: Compute in Oracle Reply with quote

Frank,

Lets say I have a variable "teacheraverage"
I would say,

BTITLE column xxx teacheraverage
and then for breaks ?

break on ..[ whats the format] here to display the variable under each
teacher's...
Back to top
maya
*nix forums beginner


Joined: 16 Feb 2005
Posts: 25

PostPosted: Thu Feb 24, 2005 5:37 pm    Post subject: Re: Compute in Oracle Reply with quote

Frank,
can u give me an example ?
Mahesh Rajendran wrote:
Quote:
I hate to say this but you are beating a dead horse

wise words.
I would take it.
Back to top
Mahesh Rajendran
*nix forums beginner


Joined: 03 May 2005
Posts: 24

PostPosted: Wed Feb 23, 2005 7:41 pm    Post subject: Re: Compute in Oracle Reply with quote

Quote:
I hate to say this but you are beating a dead horse

wise words.
I would take it.
Back to top
Frank van Bortel
*nix forums Guru


Joined: 19 Apr 2005
Posts: 804

PostPosted: Wed Feb 23, 2005 7:39 pm    Post subject: Re: Compute in Oracle Reply with quote

maya wrote:
Quote:
I will post my example one more time

Principal Teacher Student co su Percent
----------- ------------- ------------ --- --- ---
PRIN1 teach1 stud1 7 5 71
PRIN2 teach1 stud2 4 3 75
teach1 total 11 8
teach1 average 72.73

here 72.73 is the average and it is calcuated as: 8*100/11 [ from the
other totals]
Is there a way for me to display this average [ teach1 average
72.73
] in the correct location ?


Not the way you want it, but some placement is possible, using
BTITLE COL xx your_variable
Alternatively, TTITLE (Top, vs. Bottom for BTITLE).
Means you would need to introduce a page break on
each compute where you want the variable printed.

Sorry, but SQL*Plus is not a report formatter (used to
have RPT/RPF for that - it's called Oracle Reports now)
--
Regards,
Frank van Bortel
Back to top
DA Morgan
*nix forums Guru


Joined: 06 Mar 2005
Posts: 1042

PostPosted: Wed Feb 23, 2005 6:58 pm    Post subject: Re: Compute in Oracle Reply with quote

maya wrote:
Quote:
can you give some examples ?

I hate to say this but you are beating a dead horse.

Why not get a real report writer and have the ability
to write decent reports? Might I suggest Oracle
Discoverer, Crystal Reports, Cognos, etc.

Alternatively use the built-in UTL_FILE package to
write a text file and then print it.
--
Daniel A. Morgan
University of Washington
damorgan@x.washington.edu
(replace 'x' with 'u' to respond)
Back to top
maya
*nix forums beginner


Joined: 16 Feb 2005
Posts: 25

PostPosted: Wed Feb 23, 2005 5:27 pm    Post subject: Re: Compute in Oracle Reply with quote

can you give some examples ?
Back to top
Mahesh Rajendran
*nix forums beginner


Joined: 03 May 2005
Posts: 24

PostPosted: Wed Feb 23, 2005 5:22 pm    Post subject: Re: Compute in Oracle Reply with quote

I have no idea.
Not unless you make use of some pl/sql.
Back to top
maya
*nix forums beginner


Joined: 16 Feb 2005
Posts: 25

PostPosted: Wed Feb 23, 2005 5:19 pm    Post subject: Re: Compute in Oracle Reply with quote

yes, you are correct. Now I have a variable "average" which comes out
of the select statement. Is there a way to display this variable in the
location where I specify teach1 average in a sqlplus report ?
Back to top
Mahesh Rajendran
*nix forums beginner


Joined: 03 May 2005
Posts: 24

PostPosted: Wed Feb 23, 2005 5:11 pm    Post subject: Re: Compute in Oracle Reply with quote

I dont think so.
You cannot compute on a computed display ( you need some kind of
placeholder).
NOT with sql*plus.
Back to top
maya
*nix forums beginner


Joined: 16 Feb 2005
Posts: 25

PostPosted: Wed Feb 23, 2005 4:21 pm    Post subject: Re: Compute in Oracle Reply with quote

I will post my example one more time

Principal Teacher Student co su Percent
----------- ------------- ------------ --- --- ---
PRIN1 teach1 stud1 7 5 71
PRIN2 teach1 stud2 4 3 75
teach1 total 11 8
teach1 average 72.73

here 72.73 is the average and it is calcuated as: 8*100/11 [ from the
other totals]
Is there a way for me to display this average [ teach1 average
72.73
] in the correct location ?
Back to top
Mahesh Rajendran
*nix forums beginner


Joined: 03 May 2005
Posts: 24

PostPosted: Wed Feb 23, 2005 4:08 pm    Post subject: Re: Compute in Oracle Reply with quote

--
-- Used all the available functions
--
mag@mutation_mutation > get q
1 clear breaks
2 clear computes
3 set feed on
4 set term on
5 break on job
6 compute sum LABEL 'Total' -
7 avg LABEL 'Average'-
8 min LabEL 'Minimum'-
9 Max LABEL 'Maximum'-
10 of sal inc_sal comm on job
11* select job,ename,sal,(sal+100) inc_sal, nvl(comm,0) comm from emp
order by job ;
12 .
mag@mutation_mutation > @q

JOB ENAME SAL INC_SAL COMM
--------- ---------- ---------- ---------- ----------
ANALYST SCOTT 3000 3100 0
FORD 3000 3100 0
********* ---------- ---------- ----------
Average 3000 3100 0
Minimum 3000 3100 0
Maximum 3000 3100 0
Total 6000 6200 0
CLERK SMITH 800 900 0
ADAMS 1100 1200 0
MILLER 1300 1400 0
JAMES 950 1050 0
********* ---------- ---------- ----------
Average 1037.5 1137.5 0
Minimum 800 900 0
Maximum 1300 1400 0
Total 4150 4550 0
MANAGER JONES 2975 3075 0
CLARK 2450 2550 0
BLAKE 2850 2950 0
********* ---------- ---------- ----------
Average 2758.33333 2858.33333 0
Minimum 2450 2550 0
Maximum 2975 3075 0
Total 8275 8575 0
PRESIDENT KING 5000 5100 0
********* ---------- ---------- ----------
Average 5000 5100 0
Minimum 5000 5100 0
Maximum 5000 5100 0
Total 5000 5100 0
SALESMAN ALLEN 1600 1700 300
MARTIN 1250 1350 1400
TURNER 1500 1600 0
WARD 1250 1350 500
********* ---------- ---------- ----------
Average 1400 1500 550
Minimum 1250 1350 0
Maximum 1600 1700 1400
Total 5600 6000 2200
Back to top
Mahesh Rajendran
*nix forums beginner


Joined: 03 May 2005
Posts: 24

PostPosted: Wed Feb 23, 2005 3:49 pm    Post subject: Re: Compute in Oracle Reply with quote

Unfortunately , your example IS NOT READABLE.
I dont get a thing out of it.


mag@mutation_mutation > compute avg of comm on job
mag@mutation_mutation > compute sum of sal inc_sal on job
mag@mutation_mutation > break on job
mag@mutation_mutation > /

JOB ENAME SAL INC_SAL COMM
--------- ---------- ---------- ---------- ----------
ANALYST SCOTT 3000 3100 0
FORD 3000 3100 0
********* ---------- ---------- ----------
avg 0
sum 6000 6200
CLERK SMITH 800 900 0
ADAMS 1100 1200 0
MILLER 1300 1400 0
JAMES 950 1050 0
********* ---------- ---------- ----------
avg 0
sum 4150 4550
MANAGER JONES 2975 3075 0
CLARK 2450 2550 0
BLAKE 2850 2950 0
********* ---------- ---------- ----------
avg 0
sum 8275 8575
PRESIDENT KING 5000 5100 0
********* ---------- ---------- ----------
avg 0
sum 5000 5100
SALESMAN ALLEN 1600 1700 300
MARTIN 1250 1350 1400
TURNER 1500 1600 0
WARD 1250 1350 500
********* ---------- ---------- ----------
avg 550
sum 5600 6000

14 rows selected.
Back to top
Google

Back to top
Display posts from previous:   
Post new topic   Reply to topic Page 1 of 2 [28 Posts] Goto page:  1, 2 Next
View previous topic :: View next topic
The time now is Thu Jan 08, 2009 1:42 am | All times are GMT
navigation Forum index » Databases » Oracle » Tools
Jump to:  

Similar Topics
Topic Author Forum Replies Last Post
No new posts Move Oracle 10g database to another location Selt Server 0 Fri Jul 21, 2006 2:14 pm
No new posts Oracle runtime Spitfire Server 0 Fri Jul 21, 2006 1:18 pm
No new posts Oracle Text Score Computation jatinder.1975@gmail.com Server 0 Fri Jul 21, 2006 1:00 pm
No new posts Can a trigger insert records into another oracle server Tauqir Server 2 Fri Jul 21, 2006 12:27 am
No new posts Moving Oracle filesystem to SAN howard Server 1 Thu Jul 20, 2006 11:49 pm

Loans | Bankruptcy Certification | Bankruptcy | Debt Consolidation | Hacker
Copyright © 2004-2005 DeniX Solutions SRL
 
Other DeniX Solutions sites: Unix/Linux blog |  electronics forum |  medicine forum |  science forum | 
Privacy Policy


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.1785s ][ Queries: 16 (0.0753s) ][ GZIP on - Debug on ]