SQL & PL/SQL :: Compute Row Wise Multiplication For Each Unique Value Of ID?
Sep 18, 2012
how can i compute row wise multiplication for each unique value of id. I am trying to get the output as showing id and their respective results after multiplying the corresponding values.
CREATE TABLE mult_tbl(
id NUMBER,
val number
);
insert all
into mult_tbl values (1,2)
into mult_tbl values (1,3)
[code]....
View 11 Replies
ADVERTISEMENT
Nov 9, 2011
I need to multiply the values, which are in as a single column value.
Ex:
select R From awr_hist_model_ror where model_id = 60399 order by start_date
1.01
1.011
1.012
1.013
1.014
1.015
1.016
1.017
1.018
1.019
1.02
1.021
1.022
1.023
1.024
1.025
1.026
1.027
1.028
1.029
i need to multiply below column values.
View 9 Replies
View Related
Aug 14, 2013
Using Oracle 11g, below is the table, partitions, unique and non-unique local index:
CREATE TABLE DOCA( DOCA_ID NUMBER NOT NULL , DOCA_BKG_PAX_ID NUMBER NULL , ROW_PURGE_DATE DATE NULL ,)PARTITION BY RANGE(ROW_PURGE_DATE)INTERVAL(NUMTOYMINTERVAL(1, 'MONTH'))( PARTITION P2007 VALUES LESS THAN (TO_DATE('01/01/2008', 'dd/mm/yyyy')), PARTITION P200801 VALUES LESS THAN (TO_DATE('01/02/2008', 'dd/mm/yyyy')),) TABLESPACE T0; ALTER TABLE DOCA ENABLE ROW MOVEMENT;
CREATE UNIQUE INDEX XPKDOCA ON DOCA( DOCA_ID ASC, ROW_PURGE_DATE ASC)LOCALREVERSE TABLESPACE I0; ALTER TABLE DOCA ADD CONSTRAINT XPKDOCA PRIMARY KEY (DOCA_ID); CREATE INDEX XFKDOCA_DOCA_BKG_PAX_ID ON DOCA( DOCA_BKG_PAX_ID ASC)LOCALREVERSETABLESPACE I0;
I would like to know the difference between the performance of the unique and non-unique local indexes?.
View 10 Replies
View Related
Aug 28, 2010
1) Why we need to do Compute Statistic on index.
2) Is it only for optimizer to make a better plan?
3) If yes, which means, optimizer will not able to collect statistic by itself?
4) if I'm not collect statistic, then optimizer will do it or skip.
View 5 Replies
View Related
Apr 1, 2011
I'm a student researching SQL, Oracle queries. I'm currently writing a oracle:JDBC to query by id, then receive all tuples that belong to id and compute GPA. I convert letter-grade to # in query how to count rows pertaining to id, then average GPA of all tuples. I understand Count(*) where sid=?, but i need to count the rows for id, then convert letter to number, finally compute gpa for all pertaining tuples belonging to id.
Everything works find but the last query for my JDBC prog.Here is my query as of now...
"SELECT grade, CASE WHEN grade = 'F' THEN 0 WHEN grade = 'D' THEN 1 WHEN grade = 'C' THEN 2 WHEN grade = 'B' THEN 3 WHEN grade= 'A' THEN 4 END AS letter_grade FROM Grades"
How do I count all tuples then compute the gpa pertaining to id.For all IDs?
View 8 Replies
View Related
May 15, 2013
I have to create some indexes in a production database. Do I need to Compute Statistics after creating indexes? Or when I create they automatically are computed?
The version I'm using is:
Oracle Database 10g Release 10.2.0.5.0 - 64bit Production
PL/SQL Release 10.2.0.5.0 - Production
CORE 10.2.0.5.0 Production
TNS for 64-bit Windows: Version 10.2.0.5.0 - Production
NLSRTL Version 10.2.0.5.0 - Production
View 2 Replies
View Related
Jul 1, 2012
My issue is with a calculation using columns as variables. below is the code to create and attached is the code (INSERT_data.txt) to fill-in the required tables....
what's required here?
I need to update (through update or simply create new table statement)
BPF(i), BPC(i), BPY(i) of table root_tbl (A) based on InF_IDX, InC_IDX & InY_IDX and OutF_IDX, OutC_IDX & OutY_IDX using BPF(i), BPC(i), BPY(i) from table pvt_vectors_tbl(B).
Join Clause: A.P_NODE=B..P_NODE and
A.C_NODE=B.C_NODE and
A.P_NODE_Date=B.P_NODE_Date and
A.C_NODE_Date=B.C_NODE_Date
the formula are:
BPF(i):
if A.InF_IDX<=A.OutF_IDX then
FOR i=1 to A.OutF_IDX+1
if i<InF_IDX then A.BPF(i)= A.BPF(i)+ B.BPF(OutF_IDX + i - InF_IDX); else A.BPF(i)=0;
i=i+1;
else
FOR i=1 to A.InF_IDX+1
if i<OutF_IDX then A.BPF(i)= A.BPF(i)+ B.BPF(InF_IDX + i - OutF_IDX); else A.BPF(i)=0;
i=i+1;
idem for BPc and BPY.
in real word:
* root_tbl table has ~2 million records, 50 BPF(i) columns, 50 BPC(i) columns and ~475 BPY(i) columns
* pvt_vectors_tbl has ~50.000 records
/*create and fill-in pvt_vectors_tbl table*/
CREATE TABLE root_tbl
(
P_NODE VARCHAR2(3),
C_NODE VARCHAR2(3),
P_NODE_Date date,
C_NODE_Date date,
InF_IDX number,
InC_IDX number,
InY_IDX number,
[code].........
View 2 Replies
View Related
Aug 14, 2011
I am new to PL/SQL and how to create a trigger to compute the population of the school from the groups of students and store back in population. It also needs to check that there is a min of 10 students to a school.
CREATE OR REPLACE TYPE group_type AS OBJECT
(
group_nameVARCHAR2(20),
tutor_idNUMBER(5),
[code]...
View 11 Replies
View Related
Jan 30, 2012
i have a Field item on my report which i would like to show "Price INCL of VAT". Any PL/SQL code or trigger to do this? VAT is 16%
I'm a Forms programmer, not so familiar with Reports.I suspect, it should be something like this:
F_1 := F_1 * 1.16
View 25 Replies
View Related
Nov 19, 2011
the problem below:
I have a table AlertData below:
DeptIDMONTHCount
192010-041392
192010-051134
192010-061094
192010-071333
292010-042217
[Code]...
Within each DeptID group I need to calculate absolute change of 'Count' column between previous and current months and compare change value with threshold.
If ratio >= threshold N number of times I need to make a note of that event. Threshold = 0.1 N = 2 - alert needs to exceed threshold two consequtive times
Here is data processing algorithm:
1. Calculate change between month 2010-04 and 2010-05: abs((1134/1392 - 1))= 0.18;
2. check change value against threshold: 0.18 > 0.1
3. Threshold was exceeded, set alert_fired_cnt counter to = 1
4. Once alert fired it creates a baseline for comparison - I need to use Count from month 2010-04: We're now in month 2010-06: abs(1094 / 1392 - 1)=0.21
5. check change value against threshold: 0.21 > 0.1
6. Threshold was exceeded, increment alert_fired_cnt counter by 1 = 2
7. At this point alert exceede threshold two times, I need to set a alert_triggered flag = 1 and reset alert_fired_cnt = 0 for further calculations
8. We're in montn 2010-07: abs(1333/1294-1)=0.03
8. check change value against threshold: 0.03 < 0.1
9. Since threshold was not exceeded, keep alert_fired_cnt counter to = 0
Above algorithm needs to be run for all DeptID groups.
I load above data into an associative array and loop through elements. I am having trouble keeping computations within each DeptID group.
View 18 Replies
View Related
Mar 13, 2013
I have an interactive report with two columns timestamp type. I want to use the compute action in order to get the difference between those dates. Nevertheless I got values like this: +000000008 00:00:00.000000.
View 1 Replies
View Related
Jul 9, 2013
Is that possible to modify the ***** and ----- in the TEXT report?
DEPARTMENT_ID JOB_ID LAST_NAME SALARY
============= ========== ========================= ==========
20 MK_MAN Hartstein 13000
************* ********** ----------
sum 13000
From above lines, you can see ****** and ----- which are above sum&13000.
Is that possible to change them as '='?
DEPARTMENT_ID JOB_ID LAST_NAME SALARY
============= ========== ========================= ==========
20 MK_MAN Hartstein 13000
============= ========== ==========
sum 13000
"set underline =" is only shot the headers.
View 3 Replies
View Related
Oct 14, 2010
I tried BRK and COMPUTE commands myself after reading the documentation but its not working...The output of my script is correct but What I want is the information to be displayed on a different way:
Original script for the report:
set serveroutput on size 1000000
set pages 10000
set lines 1000
set arraysize 1
set trimspool on
set heading off
[code]....
The output should be exactly as above as the requirement is this should be in this particular order and how many is the count in each thoroughfare or locality, as shown in the final output, above.
View 3 Replies
View Related
Sep 11, 2012
I load a table through sql loader which takes nearly 14 min for 8-9 millions records, once the records complete i run the analyze table compute statics to gather stats and it takes nearly 15 min. is there any ways so that i can reduce the stats timing. the stats collection command runs from other schema not from where the table is residing.
View 1 Replies
View Related
Jul 2, 2011
In oracle query can i want find out how many day wise count for a year days (for example how may sundays, mondays, tuesdays, wednesdays ,thursdays,fridays,saturdays) in a given year (we can give the start day of the year and the end day of a year).
example
----------
jan sun-5 mon-4 tue-5 wed-5 thu-5 fri-4 sat-5
feb ------------do---------------------------------
like this for all 12 months at a single query.
View 3 Replies
View Related
Mar 1, 2012
I have a table which have three column.
1) empid
2) date
3) status
I want to show the value empid intime outime.
select in1.empid,in1.atttime,out.atttime from (select empid ,atttime from attend
where status=1 and to_char(atttime,'mmyyyy')='022012' order by empid,atttime desc) in1,
(select empid,atttime from attend where status =0 and to_char(atttime,'mmyyyy')='022012'
order by empid,atttime desc) out
where in1.empid=out.empid and in1.empid='02256'
order by in1.atttime,out.atttime
But this query do .one value relation with all column.means first february in time with all out time.
View 1 Replies
View Related
Jul 22, 2013
For one of our requirement, we are asked to provided data in below manner.
Deptno Deptname emp_name_1 hire_date_1 emp_name_2 hire_date_2
10 Sales Raghu 25-Jan-2007 Abbhilash 29-Mar-2009
If a particular department has 10 employees it should have data upto emp_name_10,if department has only 5 employess it should data upto emp_name_5 and so on.I came up with below approach, in this approach I need to create new table to store the data in row wise.
In my actual requirement 4 tables needs to be joined and 2 of the tables are very large.Is there any other approach without creating a new table, something within pl/sql.
drop table emp_dept;
create table emp_dept(deptno number,dept_name varchar2(100),emp_name varchar2(100),hire_date date,seq_cnt number,total_cnt number);
insert into emp_dept
[code]...
View 21 Replies
View Related
Jul 26, 2013
I want output like given below. Using EMp table . if sal is <1000 means count of Emp's who are having lessthan 1000 like that.
Deptno sal sal sal sal
<=1000 <=2000 <=3000 <= 5000
10 2 4
20 2.
View 2 Replies
View Related
Jul 1, 2011
I want to get the current month day wise count. I dont want Procedure. I need SQL Query only.For example:
July 2011.
Sunday - 5
Monday - 4
Tuesday - 4
Wednesday- 4
Thursday - 4
Friday - 5
Saturday- 5
View 3 Replies
View Related
Sep 11, 2012
I have data something like this.
Employee_id date_loggedin
123 09/10/2012
134 09/03/2012
111 09/02/2012
123 08/27/2012
134 08/01/2012
123 07/06/2012
111 05/11/2012
123 07/04/2012
123 07/03/2012
123 03/15/2012
123 01/11/2012
The desired output for input of employee_id=123 and dates between 01/01/2012 and 09/30/2012
Month login_count
JAN_2012 1
FEB_2012 0
MAR_2012 1
APR_2012 0
MAY_2012 0
JUN_2012 0
JUL_2012 3
AUG_2012 1
SEP_2012 1
View 2 Replies
View Related
Nov 2, 2010
i want create a report like this
location sysdate refdate No_of_days SL1(0-90) SL2(91-180) SL3(>180)
So when no. of days between (0-90) data put in SL1
And when no. of days between (91-180) data put in sl2
I want to achieve this only in single query.
View 11 Replies
View Related
Jul 1, 2013
OS : Windows 2003 DB : 10.2.0.4 I am doing capture and replay first time.I want to take 2 captures at a time. 1st capture for 2 schemas and 2nd capture for other schemas.Is it possible?I have searched on internet but didn't get any clue about it..
View 4 Replies
View Related
Nov 15, 2011
i am getting the data like bellow i need the data with out null values
date col1col2col3col4
16-Nov-1123
17-Nov-1112
18-Nov-11321
19-Nov-1123
20-Nov-11132
16-Nov-112321
17-Nov-11112
18-Nov-11211
19-Nov-11132
20-Nov-1112
16-Nov-1145
17-Nov-11465
18-Nov-112123
19-Nov-11132
20-Nov-1165
16-Nov-11456
17-Nov-11546
18-Nov-114656
19-Nov-11566
20-Nov-11564
need out like below
date col1col2col3col4
16-Nov-1123232145456
17-Nov-1112112465546
18-Nov-1132121121234656
19-Nov-1123132132566
20-Nov-111321265564
View 3 Replies
View Related
May 26, 2013
how could i display india as i n d i a in rowize in oracle query
output
-----------
i
n
d
i
a
(i am newbiee to this forum ,i dont know on which category i should post this question is there any general category for orcle questions?)
View 5 Replies
View Related
May 4, 2013
I have a requirement as follows :-
The user will submit the start date and end date. Based on the date parameters, the customized procedure should do some calculations month-wise.
For eg : start date - 01-Dec-2012 to end date - 31-Mar-2013
I want the break up as
Start date End date
01-dec-2012 31-dec-2012
01-jan-2013 31-jan-2013
01-feb-2013 28-feb-2013
01-mar-2013 31-mar-2013
How can i achieve this month-wise break ?
View 6 Replies
View Related
Apr 28, 2010
I have a table with starting date and ending date.
I want to fetch monthwise days for given two dates
IE starting 25/12/2009 ending 25/03/2010
Result should like below.
Dec-09 7
Jan-10 31
Feb-10 28
Mar-10 25
I have tried this but it is not giving me the result which want..
select to_char(thedate,'mon-yy') mnth,count(to_char(thedate,'mon-yy')) days from
(SELECT TRUNC(to_date('25/12/2009','dd/mm/yyyy'),'Y')+ROWNUM-1 THEDATE
FROM ( SELECT 1 just_a_column
FROM dual
CONNECT BY LEVEL <= 366
[code].....
View 3 Replies
View Related
Nov 11, 2010
Web page that retrives data from SQL database and display it to the user in well formatted manner. Data retrieved depend upon criterias selected by the user. But sometimes data retrieved is very large. I want to display records to the user page wise, i.e. 100 records on first page and next 100 records displayed when user clicks next button. This means only 100 records should be retrieved when user first select search criteria, next 100 records retrived when he clicks next button and so on, as to reduce data transferred from server to client. how to achieve this by using single sql query as soon as possible.
View 10 Replies
View Related
Feb 20, 2012
I need to query by fiscal year wise.
For example
1-Apr-2010 to 31-Mar-2011
View 11 Replies
View Related
Aug 11, 2010
Report have one parameter para name depatwhen i go to generate pdf it will ask me which dept if i pick 10 then they generate one pdf if i pick All Dept then they generate again one pdf i need seperate pdf like 10,20,30,40 generate four pdf files
View 8 Replies
View Related
Dec 11, 2012
Is there any way to capture the version wise objects (Packages) information from the oracle data base.
Ex : I have package P1 which was created on 01-NOV-2012 with version 1 . After 10 days same package has been updated version 2 with some enhancements.Like that the package will be updated according to the latest requirement.
Now I need to capture the total audit trail history of the package with version wise specific changes and when changes has been occurred hoe can I achieve this?
View 2 Replies
View Related