SQL & PL/SQL :: Finding Record In Table Having Value For Maximum Number Of Columns

Nov 25, 2011

if there is any inbuilt function or way to find a row in the table that is having value for maximum number of columns.

For example, the table A has 5 columns
(c1,c2,c3,c4,c5) and it has 3 records(r1,r2,r3)
and
r1 has values only for c1,c2
r2 has values only for c1,c2,c3,c4
r3 has values only for c1

so I should get the result as "r3 has values for 4 columns & it is not having value for column c5".

View 4 Replies


ADVERTISEMENT

SQL & PL/SQL :: Finding Maximum Value Of Two Independent Columns Of Single Table

Jan 18, 2012

The challenge I am currently facing is finding the maximum value of two independent columns of a single table. Here is the structure of the table:

[FiscalYear] [AccountingPeriod]
------------ ------------------
[2012] ------------- [2]
[2011] ------------- [12]
[2012] ------------- [1]

What I need to be able to do is to:

1) Determine the maximum value present in column FiscalYear, and then the maximum value available for this FiscalYear under the column Accounting Period.

I can do this fairly easy on Microsoft SQL server, but so far was not able to do this easily on Oracle database. My other observation is that using the MAX function on Oracle is very slow (even with thse fields being indexed). Is it possible to run this query on Oracle with only one pass through the table where the returned result will show 2012 for FiscalYear, and 2 for Accounting Period?

View 11 Replies View Related

SQL & PL/SQL :: Finding Nth Maximum Or Minimum From A Table?

Sep 17, 2011

how can i find nth maximum or minimum salary from a employee table? here i want only one row as output.

View 16 Replies View Related

Maximum Of VALUE Field Of Each Record With Different POINT-NUMBER?

Oct 21, 2011

I need to get the maximum value of the VALUE field of each record with different POINTNUMBER, then do an update on the 2nd table.

table 1
UTCTime TIMESTAMP (6)
INTEGER POINTNUMBER
FLOAT VALUE (126)
INTEGER TLQ

table 2 (idem structure)
UTCTime TIMESTAMP (6)
INTEGER POINTNUMBER
FLOAT VALUE (126)
INTEGER TLQ

Where POINTNUMBER is six thousand different values My query only returns me the maximum of a single record:

SELECT * FROM table1 WHERE value = (SELECT MAX (value) FROM table2);

And the update:
UPDATE table2 SET to a.value = (SELECT MAX (b.value) FROM table2 b);

so does on a single record.That needed to maximize each pointnumber different? I can use a cursor to do this easier?

Insertion should first make a one-time, and then updates every 1 hour

View 1 Replies View Related

SQL & PL/SQL :: Finding Next Record In Cyclic Order In Table Using Sequence

Sep 4, 2010

I have a table as below:-

CREATE TABLE TEST_EMP_WIP
(
EMP VARCHAR2(20 BYTE),
WIP NUMBER,
MAX_SEQUENCE NUMBER
)

[Code]....

EMP WIP MAX_SEQUENCE RANK
002 2 2 1
003 1 4 2
005 3 5 3
010 1 4
011 1 5

I have to find the next EMP whose MAX_SQUENCE needs to be updated with a sequence. In this case the next would be '010' I fetched the EMP who falls after the max value of the column max_sequence in order of EMPCODE.

select emp_next from (
SELECT emp,max_sequence, LEAD(emp, 1, 0) OVER (ORDER BY emp) AS emp_next
from test_emp_wip where wip > 0 )
where max_sequence=(select max(max_sequence) from test_emp_wip where wip > 0)
EMP_NEXT
010
After sometime, the record would look like :-

EMP WIP MAX_SEQUENCE RANK
002 2 2 1
003 1 4 2
005 3 5 3
010 1 6 4
011 1 7 5

Now the next update should be done to the EMP '002' in cyclic manner.

tell me a way to do this. I can insert new columns if needed in table for calculation.

View 5 Replies View Related

PL/SQL :: Finding The Maximum Truncate (date)

Jul 31, 2012

I've the following data set

with t as
(
select 1 cor_id , 'SR' rt_cd,TO_Date( '05/12/2010 01:12:19 PM', 'MM/DD/YYYY HH:MI:SS AM') dt,100 iss_id from dual union all
select 2 cor_id , 'SL' rt_cd,TO_Date( '05/12/2010 01:12:18 PM', 'MM/DD/YYYY HH:MI:SS AM') dt,100 iss_id from dual union all
select 3 cor_id , 'SR' rt_cd,TO_Date( '04/10/2010 02:11:15 PM', 'MM/DD/YYYY HH:MI:SS AM') dt,100 iss_id from dual union all
select 4 cor_id , 'SL' rt_cd,TO_Date( '04/10/2010 01:12:18 PM', 'MM/DD/YYYY HH:MI:SS AM') dt,100 iss_id from dual
)
select t1.*
from t t1for each iss_id =100 ,

there could me more than one record in the above data set, The requirement is i need to get the records where the trunc(dt) is maximum

I need to get 2 records with cor_id= 1 and 2.

how can i get those records

View 3 Replies View Related

Express Edition (XE) :: Why Maximum Number Of Voting Disk Is Even Number (32)

Oct 3, 2013

I gone through many forums and found that the number of voting disks should be always in odd number. Then why the maximum number of voting disk is 32?

View 1 Replies View Related

SQL & PL/SQL :: Count A List Of Number Value And Find Maximum Number?

May 21, 2010

how do I count a list of number value eg 1,1,1,1,3,3,6,4 and find the one with maximum number which is 1

View 5 Replies View Related

Forms :: INSERT Record - Update Columns Of Table

May 31, 2010

I would like to UPDATE the columns p1 and p2 of my table student (studentid:pk,name,p1,p2,...) for a given studentid.and I have a when-button-pressed trigger with this

UPDATE student
SET student.p1=:validation.proj1,
student.p2=:validation.proj2
where UPPER(student.studentid)=UPPER(:validation.studentid);commit_form;

when I run my form with a correct studentid, I got this error: FRM-40508: ORACLE error: UNABLE to INSERT record

but it is cworking correctly in sqlplus; and I have all priveligies.

View 4 Replies View Related

Query To Know Number Of Columns In A Table?

Apr 4, 2008

query to know number of columns in a table i.e.

if I want to know how many number of colums are present in a specific table then what would be the query.

View 1 Replies View Related

SQL & PL/SQL :: Update Number Of Rows In Three Columns In Table?

Dec 13, 2011

how to update the middle of plenty rows in the middle of the columns

sample_data

id name state REGION LOC
1 v A.p 1 1
2 a
3 g K.A 0 3
4 y
5 i T.N 1 0
6 l M.P 0 1
7 c U.P

This is sample data,and i have this kind of large data and i need to fill the rows which are empty. In three columns state,region,loc with data like 0,web_intimation,1,

View 8 Replies View Related

SQL & PL/SQL :: Add Variable Number Of New Columns To Existing Table Temp

Feb 24, 2010

I want to add a variable number of new columns to an existing table temp (with column provided).

Example:

NewColumnNo = 4
-> the columns shall be named rate_1, rate_2, rate_3 and rate_4
-> the values shall be = Column / NewColumnNo

The result shall be like this:

create table temp_res (prodid integer, rate_1 number, rate_2 number, rate_3 number, rate_4 number);
insert into temp_res values(1, 0.25, 0.5, 0.75, 1);
insert into temp_res values(2, 0.25, 0.5, 0.75, 1);
insert into temp_res values(3, 0.25, 0.5, 0.75, 1);
insert into temp_res values(4, 0.25, 0.5, 0.75, 1);
insert into temp_res values(5, 0.25, 0.5, 0.75, 1);
insert into temp_res values(6, 0.25, 0.5, 0.75, 1);
insert into temp_res values(7, 0.25, 0.5, 0.75, 1);
insert into temp_res values(8, 0.25, 0.5, 0.75, 1);
insert into temp_res values(9, 0.25, 0.5, 0.75, 1);

View 8 Replies View Related

Finding Correlation Using Derived Columns?

May 13, 2007

I want to use the aggregate CORR_S function which take two numerical columns and output the correlation between them. Assuming I have the table:

Employee(name, gender, salary) where I want to create two derived columns, how would I do it?

Like,
-------------------
SELECT CORR_S(
SELECT salary
FROM employees
WHERE salary < 10000,
SELECT salary
FROM employees
WHERE salary > 10000
) as correlation
FROM employees
---------------------

It will find the correlation between salary's less than $10,000 in one column and salary's more than $10,000 in another column. Of course, I get an error when running the query. It's no problem if I use CORR_S(salary, salary) but I want to use derived columns, is it possible? Or, will I need to create a new table view with two new columns CORR_S(lowSalary, highSalary)?

View 1 Replies View Related

Application Express :: How To Show Data From A Table Having Large Number Of Columns

Oct 8, 2013

I have a report with single row having large number of columns . I have to use a scroll bar to see all the columns. Is it possible to design report in below format(half columns on one side of page, half on other side ofpage : 

Column1DataColumn11DataColumn2DataColumn12DataColumn3DataColumn13DataColumn4DataColumn14DataColumn5DataColumn15DataColumn6DataColumn16DataColumn7DataColumn17DataColumn8DataColumn18DataColumn9DataColumn19DataColumn10DataColumn20Data I am using Apex 4.2.3 version on oracle 11g xe.

View 2 Replies View Related

SQL & PL/SQL :: Finding Value Of Bits From Hex Number?

Jan 12, 2012

Version : Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production

I have a source which is of datatype RAW(1). Basic requirement is to convert it into binary, and then lookup the value of the 4th and 6th bit. Is this possible using simple SQL ?

Eg.

DataBinary
----- -------
EF1110 1111

From this binary output, i need to find the value of 4th and 5th bit.
So if the 4th bit is 1, I need to perform some operations if 0 then some other.

Create table test_hex_to_bin (col1 raw(1));

INSERT into test_hex_to_bin values ('99');
INSERT into test_hex_to_bin values ('EF');
INSERT into test_hex_to_bin values ('AB');

Basically the output should read as

Bit_number Value
----------------
4 1
5 0

View 5 Replies View Related

SQL & PL/SQL :: Finding Number Of Pattern Occurrences In String?

Feb 4, 2012

The code which I am working on consists of an incoming dynamic string which be in the form of binary digits. The max size of the string will be 12 digits. For example, the string can be '111011000001', '000000000000', '111111011111', etc.

I need to find the number of occurences of '111' in the incoming string. Say in the 1st example, result will be 1, in the 2nd example result will be 0, and in the third example, the result will be 3.

I have been trying to capture the string length and replacing the variables '111' to find the number of occurences, but it isn't giving me the result that I want. This is what I have tried

SQL> conn hr/hr
Connected.
SQL> show user
USER is "HR"

[Code]....

I searched the forum and found a similar topic, and following that guideline, I even tried dividing the string with the length of the pattern. It works in some scenarios (the first and second examples mentioned below), while it fails in some scenarios (third example mentioned below)

SQL> select (length('11101110111') - length(replace('11101110111','111','')))/length('111') as occurences from dual;

OCCURENCES
----------
3

SQL> select (length('110111110111') - length(replace('110111110111','111','')))/length('111') as occurences from dual;

OCCURENCES
----------
2

SQL> select (length('111111111111') - length(replace('111111111111','111','')))/length('111') as occurences from dual;

OCCURENCES
----------

SQL>

View 13 Replies View Related

SQL & PL/SQL :: How Many Maximum Number Of Bind Variables

Mar 10, 2010

How many maximum number of bind variables,can we use in Execute Immediate.

View 2 Replies View Related

SQL & PL/SQL :: DBMS_JOB / Maximum Number Of Failures A Job Can Allow

Mar 9, 2010

What is the maximum number of failures a job can allow,when we are scheduling jobs using DBMS_JOB.

View 1 Replies View Related

ORA-00020 Maximum Number Of Processes

Aug 23, 2012

select * from v$version;

BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
PL/SQL Release 11.2.0.2.0 - Production
CORE    11.2.0.2.0      Production
TNS for IBM/AIX RISC System/6000: Version 11.2.0.2.0 - Production
NLSRTL Version 11.2.0.2.0 - ProductionI got below error on the datases.

ORA-00020: maximum number of processesBased on the suggestion got from previous posts, I did kill some (LOCAL=NO) processes to get myself in. When I looked at the number of processes the number is 150, I changed it to 1000. After a day I got the same error.

ORA-00020: maximum number of processes (1000) exceededI killed processes again to let my self in, bases on the post below, I queried database

ORA-00020: maximum number of processes (%s) exceededHere is the query to find out if there are any processes with out session attached to it.

select spid from v$process where addr not in (select paddr from v$session);Result

SPID
null
35259840
36897866
13369762

[Code]...

To determine the from where greatest number of processes originated

SELECT MACHINE, COUNT(*) FROM V$SESSION GROUP BY MACHINE;Machine     Count(*)
     2
CAPITAL-D3F0092     1
DQAKDCDKLCSW01     14
desmond     20
DQAKDCDKLCSA01     52

My question is why I am keep getting this? Why do increasing process from 150 to 1000 did not resolve the issue?

What can I do to make sure that I don't get this error again?

View 1 Replies View Related

Forms :: Finding Out Port Number And Oracle ID For Compilation?

May 21, 2010

Is there any way i could figure out what is the current port number used in an existing setup of oracle forms in a linux server.

Is there any specific oracle id i should use to compile oracle forms on server?

View 5 Replies View Related

Maximum Number Of Processes (1100) Exceeded

Sep 16, 2011

i got this error..

ORA-00020: maximum number of processes (1100) exceeded

my oracle version is 10.2.0.2.0

when i was trying to login to oracle i got :ERROR at line 1: ORA-01012: not logged on

lucky i was having another sqlplus login ..

wht i should do to bring the number of process down without increasing the process value and shuting/restaring down db.

"Usually, when this happens, I want to get connected to the instance, so that I can try to figure out which user is causing the problem. One way to do that is to use the 'ps' command to identify some of the oldest server processes, and kill the 3-5 oldest processes, and then quickly try connecting to the database. Once you're in, you can look at things like V$SESSION to try and determine which user(s) is (are) consuming so many connections, and then go from there."

this is what i got from [URL]....

1.if i am giving ps -ef in OS it will give lot of detail ...
2. in v$session wht i should look for ....

View 4 Replies View Related

SQL & PL/SQL :: ORA-00020 Maximum Number Of Processes 150 Exceeded

Jun 9, 2013

I don't know if there is a beginner forum out there for PL SQL, but I cannot find one.I just started taking an Intermediate Oracle course to learn PL SQL. Today is my first day and I just installed Oracle 11g. I was in SQL Plus, tried the edit command. I got the message "wrote file Afiedt.buf" and then it was just a flashing cursor in the line below. I could not type any commands. I just hit the X to close the program.

What could I have done to exit the program with that flashing cursor since I was unable to type anything?

View 7 Replies View Related

PL/SQL :: Dynamically Get Maximum Value Permitted In A Number Column?

May 18, 2013

How can we dynamically get maximum value permitted in a number column? Is there any in-built function in oracle for this?

e.g. Accrued_Interest NUMBER(10,4)

In this case maximum value that can be inserted in this column is "999999.9999".

View 2 Replies View Related

Maximum Number Of Processes Per Database User

Jun 1, 2013

I am using Oracle 11g R2. (11.2.0.3)

I know that in the profiles of the user I can set limit for the number of sessions per database user, using the below command:

alter profile <profile_name> limit sessions_per_user=<required_number>;

I need to set maximum number of processes for the application user so in case they opened too many number of processes on the database they do not block the automated jobs to be run.My questions:

1. set a limit on sessions_per_user is it the same as a limit on processes? 1 proccess= 1 session ? Is there any way to limit the number of processes (not sessions) for a database user?
2. I am using RAC so the number of sessions is per the whole database, while the max number of processes is by instance (not database), so even I set a limit on the number of sessions (above the limit of processes for one of the instances) one instance may face ORA-20 errors, while the max number of sessions did not hit the limit. is there any workaround for this case?

View 5 Replies View Related

RMAN Error Maximum Number Of 128 Rows Exceeded

Nov 2, 2010

I read the error description. In my case there is only one full backup at a time running, hence it does not make any sense.

RMAN>
connected to target database: OTATEST (DBID=3130218754)
RMAN-06900: WARNING: unable to generate V$RMAN_STATUS or V$RMAN_OUTPUT row
RMAN-06901: WARNING: disabling update of the V$RMAN_STATUS and V$RMAN_OUTPUT row
s
ORACLE error from target database:
ORA-19921: maximum number of 128 rows exceeded

SQL> select count(*) from V$RMAN_STATUS;

COUNT(*)
----------
560

SQL> select count(*) from V$RMAN_OUTPUT;

COUNT(*)
----------
32834

View 1 Replies View Related

Server Administration :: Maximum Number Of Connection Of Particular User?

May 2, 2012

how many maximum connection, a particular user can have in oracle. and how many maximum connection if user has 'resource profile' as default.and i am using oracle 11.2.0.1.0

View 1 Replies View Related

SQL & PL/SQL :: ORA-00036 Error (maximum Number Of Recursive Levels)

Aug 19, 2010

Ive just tried running a simple

update BASIC set 'column name' = NULL

Which works fine if i specify a where clause that returns a low amount of values, but im trying to run this update for the whole column (1000's or records).

Ive had no experience of this error before and am unsure of where to start, ive had a quick read around but see something of removing triggers?

The full error is :

ORA-00036: maximum number of recursive SQL levels (50) exceeded
ORA-06512: at "new.su_Table", line 61

View 22 Replies View Related

PL/SQL :: Trigger Error Maximum Number Of Recursive SQL Levels

Aug 29, 2012

I have getting error will insert into table i.e

i have a trigger as below

create or replace trigger INS_ERRORS
before insert on MIG_STG_ERRORS
for each ROW
declare
V VARCHAR2(22);
[code]........ 

when i insert into MIG_STG_ERRORS getting error message like 00036. 00000 - "maximum number of recursive SQL levels (%s) exceeded"

*Cause:    An attempt was made to go more than the specified number of recursive SQL levels.
*Action:   Remove the recursive SQL, possibly a recursive trigger.

View 4 Replies View Related

Server Administration :: ORA-00020 / Maximum Number Of Processes (400) Exceeded

Aug 9, 2013

To investigate further on this error ,i want to find how many user connections got established during the error time and their details like machine,username,program,status etc in database ?

View 6 Replies View Related

Reports & Discoverer :: Using Parameter For Maximum Rows To Fetch To Be A Number

Dec 15, 2010

In Report it is possible to set the maximum rows to fetch to be a number e.g. 1+.Is it possible to use a number that is selected from another query? When I try to do this i.e. I put in the field num_lines or :num_lines I just get invalid number

View 10 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved