How to find the maximum value in a collection
Hi allI'm using Oracle 11 g 2. I need to know the maximum value in a collection of items.
When I run the following, I get the maximum number of collection as '5' but I need the max value itself which is 8, please help.
DECLARE
type v_number1 is table of number of directory indexes;
v_number v_number1;
IDX NUMBER.
psrc_file VARCHAR2 (10): = '1,2,4,8,6';
v_src_file_string_array v_number1;
number of max_temp;
BEGIN
SELECT regexp_substr (psrc_file, "[^,] +', 1, level") coll
LOOSE COLLECTION v_src_file_string_array
FROM (SELECT psrc_file FROM dual)
CONNECTION OF LEVEL < = length (regexp_replace (psrc_file, "[^,] +")) + 1;
-Set up some test values:
BECAUSE me IN v_src_file_string_array. FIRST... v_src_file_string_array. COUNTING LOOP
-v_numbers (i): = v_src_file_string_array (i);
v_number (i): = i;
END LOOP;
max_temp: = v_number (v_number.first);
IDX: = v_number.first;
-Display the contents of the table:
While the idx is not null
loop
If (idx) v_number > = max_temp
then
max_temp: = v_number (idx);
end if;
IDX: = v_number.next (idx);
end loop;
dbms_output.put_line ('Max: ' | max_temp);
end;
/
Thank you!
Harinath Arasu says:
Hi allI'm using Oracle 11 g 2. I need to know the maximum value in a collection of items.
When I run the following, I get the maximum number of collection as '5' but I need the max value itself which is 8, please help.
DECLARE
type v_number1 is table of number of directory indexes;v_number v_number1;
IDX NUMBER.
psrc_file VARCHAR2 (10): = '1,2,4,8,6';
v_src_file_string_array v_number1;
number of max_temp;BEGIN
SELECT regexp_substr (psrc_file, "[^,] +', 1, level") coll
LOOSE COLLECTION v_src_file_string_array
FROM (SELECT psrc_file FROM dual)
CONNECT BY LEVEL<= length(regexp_replace(psrc_file,="" '[^,]+'))="" +="">=>-Set up some test values:
BECAUSE me IN v_src_file_string_array. FIRST... v_src_file_string_array. COUNTING LOOP
It should be-online 1... v_src_file_string_array. COUNTY
-v_numbers (i): = v_src_file_string_array (i);
v_number (i): = i;
This should be-online v_numbers (i): = v_src_file_string_array (i);
Can't do you all just...
DECLARE
type v_number1 is table of number index by binary_integer;
v_number v_number1;
idx NUMBER;
psrc_file VARCHAR2(10) := '1,2,4,8,6';
v_src_file_string_array v_number1;
max_temp number;
BEGIN
SELECT regexp_substr(psrc_file, '[^,]+', 1, level) coll
BULK COLLECT INTO v_src_file_string_array
FROM (SELECT psrc_file FROM dual)
CONNECT BY LEVEL <= length(regexp_replace(psrc_file, '[^,]+')) + 1;
FOR i IN 1..v_src_file_string_array.COUNT LOOP
if max_temp is null or
v_src_file_string_array(i) > max_temp then
max_temp := v_src_file_string_array(i);
end if;
END LOOP;
dbms_output.put_line ('Max: ' || max_temp);
end;
Or more simply...
DECLARE
type v_number1 is table of number index by binary_integer;
v_number v_number1;
idx NUMBER;
psrc_file VARCHAR2(10) := '1,2,4,8,6';
v_src_file_string_array v_number1;
max_temp number;
BEGIN
SELECT to_number(regexp_substr(psrc_file, '[^,]+', 1, level))
BULK COLLECT INTO v_src_file_string_array
FROM (SELECT psrc_file FROM dual)
CONNECT BY LEVEL <= length(regexp_replace(psrc_file, '[^,]+')) + 1
order by 1 desc;
dbms_output.put_line ('Max: ' || v_src_file_string_array(1));
end;
Published by: JAC on April 3, 2013 18:56
Unhandled exception...
Tags: Database
Similar Questions
-
How to find the maximum value of the alphanumeric column
Hello
I have following data varchar column.
USR_UDF_ALPHANUMERIC
--------------------------------
234123
CS/123762
987643
CS/990087
999999
CS/761287
I'm looking to separate the 2 SQL queries which should get the output as CS/990087 for the first query and * 999999 * for the second query.
database is 10g.As always: it is documented.
See:
http://download.Oracle.com/docs/CD/B19306_01/server.102/b14200/functions043.htm#i1064409And make a few quick searches yourself:
http://www.Oracle.com/pls/db102/homepage
or
http://www.Oracle.com/pls/db112/homepage -
Hi all
I have a system of LabVIEW which takes advantage IMAQ tools and features of the Vision Development Module. A useful feature that I put in place is to be able to take a snapshot of the video stream and then subtract this single image among the subsequent images.
What I want to do is to collect a series of images instead of one, and then create a unique image of these frameworks is just the maximum value of pixels in each pixel (a bit like a display persistent).
It would probably be very easy to be implemented by converting the image to a table and then by doing math number on the table and then turning into an image, but I hope that someone here may know how to use the IMAQ/VDM tools to do this in a way more compact.
Thank you very much
MK
How about using Max comparison IMAQ operation?
-
How to set the maximum value of the slide in run mode
Hello
I have a number of files to process, the files are going to be covered in the runtime. I want to use a slider that controls a single in the process at some point file. As the total number of files cannot be pre-be determined, I wonder how I can configure the maximum value of the slider when running (after I know how many files in the pool).
Any help will be greatly appreciated.
JACIE
Right-click on the property and select change writing. Now you can wire a constant to the property node.
-
How to find the ASCII value of the TAB?
Hi friends,
I'm trying to find the ASCII value of the TAB character using ASCII standard as:
SELECT ASCII ('< TAB >') FROM DUAL;
I'm running the command above in SQL * more.
Is not treated as TAB.
It is considered space and give the ASCII value of the space - 32.
Please let me know how?
Version of Database - 9i
Concerning
Anthony Alix.Its only editor that gives you the problem; Try it on TOAD or sql developer, it works perfectly.
Is there a particular reason you want in sql * more?
-
How to find the maximum and minimum of a waveform between cursors
Hello!
Does anyone know an easy way to find the maximum and minimum of a waveform between two sliders?
Kind regards
Andreas
Hi Andreas,
attached, you get an example of it in MeasurementStudio.
-
How to choose the maximum value in a column of a table by using the cursor and iteration
Hello everyone
I have a table loan_detail
and a column inside loan_amount
now I want to take the values in this table with the cursor, then using iteration that I want to take a max value of him using this slider
Here is my table
I could make using the concepts of single loop, but when I tried to do by using the slider I wasn't able to do.LOAN_AMOUNT 100 200 300 400 500 5600 700
Concerning
ProstYou can get the maximum value for a particular column in SQL, PLSQL needn't; Always avoid PLSQL so you can do it in SQL. But always as an example:
declare
number of Temp: = 0;
Start
for news in some loan_amt of loan_detail
loop
If (temp
end if;
end loop;
dbms_output.put_line (temp);
end;Edited by: Mahanam January 5, 2011 03:11
-
How to find the max value of scrollV in AS3?
I used the response from Ned to get my 3 fields of scrolling text set based on the value of one of them. Thanks Ned!
The other two text fields scroll to match the text box 'parent', but in the end – you get to the last scroll position - the other two do not update and 3 text fields are out of alignment. It's just at the end of the roll. The rest of the scroll values line up. I think that if I can find the scrollV max value, I can force the two others to scroll one last time when this value is reached by the text field "parent".
The textfield object has a property for this: maxScrollV.
-
How to find the last value of the row in a Datagrid?
Hello world
Thanks in advance.
I need your help to find the latest data from the line in the Datagrid control.
In fact I use Datagrid to display my data in flex. In my data, I stored the value of gender of the employees. So if the last row in my datagrid 'female' I need to highlight this particular line. So please help me to solve this problem.
Thank you
Charles. J
mylastrowitem dg.dataProvider.getItemAt = (dg.dataProvider.length - 1).
-
SQL: How to get the maximum value of loans
I have to display cod_acct_no, amt_disbursed, bal_book in table LOAN_MAST and maximum version of table LOAN_SCHEDULE CTR_STAGE_NO amt_instal. in other words; amt_instal of the most ctr_stage_no of table LOAN_SCHEDULE to display with the other value of LOAN_MAST column.
You could help me pls.
Data from these two tables are provided below:
Main table ready
Table of loan from schedule+:INSERT INTO loan_mast VALUES ('00057110000431 ',2000000,1010605.39) / INSERT INTO loan_mast VALUES ('00057110000291 ',3500000,1212038.57) / INSERT INTO loan_mast VALUES ('00057110000450 ',2000000,1179199.79) / INSERT INTO loan_mast VALUES ('00057010001457 ',2000000,1555836.32) / INSERT INTO loan_mast VALUES ('00057010001650 ',9500000,8060419.1) / INSERT INTO loan_mast VALUES ('00057110050065 ',2000000,1742388.45) / INSERT INTO loan_mast VALUES ('00057010001947 ',2000000,1933540.07) / INSERT INTO loan_mast VALUES ('00057110050213 ',2000000,1978588.06) / INSERT INTO loan_mast VALUES ('00037010001104 ',6175000,3241694.48) / INSERT INTO loan_mast VALUES ('00037010001766 ',12000000,11715781.01) / INSERT INTO loan_mast VALUES ('00037300050025 ',7500000,7472981.78) / INSERT INTO loan_mast VALUES ('00037210000694 ',6500000,6588648.16) / INSERT INTO loan_mast VALUES ('00017210000087 ',5000000,4105246.38) / INSERT INTO loan_mast VALUES ('00017210000129 ',5000000,3478303.49) / INSERT INTO loan_mast VALUES ('00017210000141 ',5000000,3685293.79) / INSERT INTO loan_mast VALUES ('00017210000246 ',5000000,4029883.61) / INSERT INTO loan_mast VALUES ('00017210000268 ',5000000,4499322.1) / INSERT INTO loan_mast VALUES ('00017210000322 ',5000000,4966885.32) / INSERT INTO loan_mast VALUES ('00017300050014 ',7000000,6625970.85) / INSERT INTO loan_mast VALUES ('00017300050036 ',5700000,5687617.61) / INSERT INTO loan_mast VALUES ('00017300050047 ',7500000,7527560) / INSERT INTO loan_mast VALUES ('00017240000050 ',4300000,4300000) / INSERT INTO loan_mast VALUES ('00017210000449 ',7000000,7000000) / INSERT INTO loan_mast VALUES ('03017180001733 ',500000,335164.83) / INSERT INTO loan_mast VALUES ('01117110050071 ',700000,625123.9) / INSERT INTO loan_mast VALUES ('01077300050011 ',1500000,1447149.08) / INSERT INTO loan_mast VALUES ('00927180002119 ',500000,441488.25) / INSERT INTO loan_mast VALUES ('01507150051043 ',700000,633340.47) / INSERT INTO loan_mast VALUES ('03317290050040 ',300000,273601.45) / INSERT INTO loan_mast VALUES ('01027150051360 ',200000,179240.42) / INSERT INTO loan_mast VALUES ('01067150052782 ',300000,270794.1) / INSERT INTO loan_mast VALUES ('01137110050082 ',2000000,1786359.87) / INSERT INTO loan_mast VALUES ('01107150050610 ',200000,191399.56) / INSERT INTO loan_mast VALUES ('01117150051071 ',300000,271560.17) / INSERT INTO loan_mast VALUES ('01017210001052 ',6800000,6609837.58) / INSERT INTO loan_mast VALUES ('01157010001078 ',450000,425069.61) / INSERT INTO loan_mast VALUES ('00017180001173 ',700000,484447.94) / INSERT INTO loan_mast VALUES ('09997120004696 ',93099,64369.52) / INSERT INTO loan_mast VALUES ('01067010001654 ',285000,255579.7) / INSERT INTO loan_mast VALUES ('01017210001063 ',7000000,6930746) / INSERT INTO loan_mast VALUES ('01017210001105 ',7000000,6934246) / INSERT INTO loan_mast VALUES ('01017210001138 ',7000000,7000000) / INSERT INTO loan_mast VALUES ('01017210001116 ',7000000,7000000) / INSERT INTO loan_mast VALUES ('01017210001161 ',7000000,7000000) / INSERT INTO loan_mast VALUES ('01017210001150 ',7000000,7000000) / INSERT INTO loan_mast VALUES ('01017210001127 ',7000000,6930746) / INSERT INTO loan_mast VALUES ('00067110050043 ',700000,602416.77) / INSERT INTO loan_mast VALUES ('01147150052362 ',200000,178682.78) / INSERT INTO loan_mast VALUES ('01167150051647 ',75000,60057.01) / INSERT INTO loan_mast VALUES ('01017150053252 ',150000,125205.66) / INSERT INTO loan_mast VALUES ('00917150050232 ',100000,91972.04) / INSERT INTO loan_mast VALUES ('01017180003081 ',990000,663015.26) / INSERT INTO loan_mast VALUES ('09997220000893 ',154160,138665.08) / INSERT INTO loan_mast VALUES ('01017210000955 ',5000000,4510523.32) / INSERT INTO loan_mast VALUES ('00087150001049 ',1000000,904601.41) / INSERT INTO loan_mast VALUES ('01107010000288 ',300000,268703.55) / INSERT INTO loan_mast VALUES ('00087150001038 ',1000000,906085.9) / INSERT INTO loan_mast VALUES ('01107010000277 ',200000,184905.75) / INSERT INTO loan_mast VALUES ('00017080050030 ',500000,450047.42) / INSERT INTO loan_mast VALUES ('00037210000533 ',4000000,3346908.17) / INSERT INTO loan_mast VALUES ('01117180000631 ',990000,712874.67) / INSERT INTO loan_mast VALUES ('02007180001216 ',990000,792437.11) / INSERT INTO loan_mast VALUES ('01957180000928 ',400000,320317.9) / INSERT INTO loan_mast VALUES ('00037210000544 ',600000,518404.4) / INSERT INTO loan_mast VALUES ('01117110050060 ',1000000,893034.07) / INSERT INTO loan_mast VALUES ('00037180001877 ',800000,640405) / INSERT INTO loan_mast VALUES ('01047150052651 ',320000,288850.72) / INSERT INTO loan_mast VALUES ('01027160050103 ',100000,79915.86) / INSERT INTO loan_mast VALUES ('01067150052759 ',150000,129601.15) / INSERT INTO loan_mast VALUES ('01057150051287 ',800000,723681.12) / INSERT INTO loan_mast VALUES ('03317290050021 ',400000,359312.25) / INSERT INTO loan_mast VALUES ('01157150051316 ',500000,452300.73) / INSERT INTO loan_mast VALUES ('00037150050598 ',700000,633221.03) / INSERT INTO loan_mast VALUES ('01047150052673 ',150000,129610.95) / INSERT INTO loan_mast VALUES ('01147150052384 ',400000,361840.54) / INSERT INTO loan_mast VALUES ('01067150052802 ',150000,130840.94) / INSERT INTO loan_mast VALUES ('01157150051338 ',300000,259202.22) / INSERT INTO loan_mast VALUES ('01057150051307 ',400000,361840.54) / INSERT INTO loan_mast VALUES ('00017110050160 ',500000,397640.38) / INSERT INTO loan_mast VALUES ('01077150050910 ',100000,79915.86) / INSERT INTO loan_mast VALUES ('00057150050702 ',400000,360841.83) / INSERT INTO loan_mast VALUES ('01017150053271 ',150000,119955.86) / INSERT INTO loan_mast VALUES ('01057150051329 ',400000,360029.85) / INSERT INTO loan_mast VALUES ('01067150002665 ',500000,452300.73) / INSERT INTO loan_mast VALUES ('01077150050921 ',250000,225526.17) / INSERT INTO loan_mast VALUES ('00047150050693 ',200000,160494.64) / INSERT INTO loan_mast VALUES ('01077080050026 ',100000,91150.55) / INSERT INTO loan_mast VALUES ('01017150053293 ',150000,129675.2) / INSERT INTO loan_mast VALUES ('09997040001950 ',2500000,2439161.01) / INSERT INTO loan_mast VALUES ('09997120004685 ',75000,51855.74) /
Kind regardsINSERT INTO loan_schedule VALUES ('00017080050030 ',1,12426.29) / INSERT INTO loan_schedule VALUES ('00017110050160 ',1,0) / INSERT INTO loan_schedule VALUES ('00017110050160 ',2,17702.2) / INSERT INTO loan_schedule VALUES ('00017180001173 ',1,0) / INSERT INTO loan_schedule VALUES ('00017180001173 ',2,35116.22) / INSERT INTO loan_schedule VALUES ('00037150050598 ',1,0) / INSERT INTO loan_schedule VALUES ('00037150050598 ',2,18158.39) / INSERT INTO loan_schedule VALUES ('00037180001877 ',1,0) / INSERT INTO loan_schedule VALUES ('00037180001877 ',2,29122.98) / INSERT INTO loan_schedule VALUES ('00037210000533 ',1,0) / INSERT INTO loan_schedule VALUES ('00037210000533 ',2,144609.59) / INSERT INTO loan_schedule VALUES ('00037210000544 ',1,0) / INSERT INTO loan_schedule VALUES ('00037210000544 ',2,17625) / INSERT INTO loan_schedule VALUES ('00047150050693 ',1,0) / INSERT INTO loan_schedule VALUES ('00047150050693 ',2,7331.21) / INSERT INTO loan_schedule VALUES ('00057150050702 ',1,0) / INSERT INTO loan_schedule VALUES ('00057150050702 ',2,10157.38) / INSERT INTO loan_schedule VALUES ('00067110050043 ',1,20017.91) / INSERT INTO loan_schedule VALUES ('00087150001038 ',1,0) / INSERT INTO loan_schedule VALUES ('00087150001038 ',2,25940.56) / INSERT INTO loan_schedule VALUES ('00087150001049 ',1,0) / INSERT INTO loan_schedule VALUES ('00087150001049 ',2,25940.56) / INSERT INTO loan_schedule VALUES ('00917150050232 ',1,2937.5) / INSERT INTO loan_schedule VALUES ('00927180002119 ',1,0) / INSERT INTO loan_schedule VALUES ('00927180002119 ',2,25083.02) / INSERT INTO loan_schedule VALUES ('01017150053252 ',1,5422.86) / INSERT INTO loan_schedule VALUES ('01017150053271 ',1,0) / INSERT INTO loan_schedule VALUES ('01017150053271 ',2,5422.86) / INSERT INTO loan_schedule VALUES ('01017150053293 ',1,0) / INSERT INTO loan_schedule VALUES ('01017150053293 ',2,4406.25) / INSERT INTO loan_schedule VALUES ('01017180003081 ',1,0) / INSERT INTO loan_schedule VALUES ('01017180003081 ',2,49664.37) / INSERT INTO loan_schedule VALUES ('01017210000955 ',1,0) / INSERT INTO loan_schedule VALUES ('01017210000955 ',2,126967.14) / INSERT INTO loan_schedule VALUES ('01027150051360 ',1,0) / INSERT INTO loan_schedule VALUES ('01027150051360 ',2,5980.03) / INSERT INTO loan_schedule VALUES ('01027160050103 ',1,0) / INSERT INTO loan_schedule VALUES ('01027160050103 ',2,3615.24) / INSERT INTO loan_schedule VALUES ('01047150052651 ',1,0) / INSERT INTO loan_schedule VALUES ('01047150052651 ',2,8125.9) / INSERT INTO loan_schedule VALUES ('01047150052673 ',1,0) / INSERT INTO loan_schedule VALUES ('01047150052673 ',2,4406.25) / INSERT INTO loan_schedule VALUES ('01057150051287 ',1,0) / INSERT INTO loan_schedule VALUES ('01057150051287 ',2,20752.45) / INSERT INTO loan_schedule VALUES ('01057150051307 ',1,0) / INSERT INTO loan_schedule VALUES ('01057150051307 ',2,10376.23) / INSERT INTO loan_schedule VALUES ('01057150051329 ',1,0) / INSERT INTO loan_schedule VALUES ('01057150051329 ',2,11960.05) / INSERT INTO loan_schedule VALUES ('01067010001654 ',1,0) / INSERT INTO loan_schedule VALUES ('01067010001654 ',2,6855.16) / INSERT INTO loan_schedule VALUES ('01067150002665 ',1,0) / INSERT INTO loan_schedule VALUES ('01067150002665 ',2,12970.28) / INSERT INTO loan_schedule VALUES ('01067150052759 ',1,0) / INSERT INTO loan_schedule VALUES ('01067150052759 ',2,4406.25) / INSERT INTO loan_schedule VALUES ('01067150052782 ',1,0) / INSERT INTO loan_schedule VALUES ('01067150052782 ',2,7618.03) / INSERT INTO loan_schedule VALUES ('01067150052802 ',1,0) / INSERT INTO loan_schedule VALUES ('01067150052802 ',2,5422.86) / INSERT INTO loan_schedule VALUES ('01077080050026 ',1,0) / INSERT INTO loan_schedule VALUES ('01077080050026 ',2,2485.26) / INSERT INTO loan_schedule VALUES ('01077150050910 ',1,0) / INSERT INTO loan_schedule VALUES ('01077150050910 ',2,3615.24) / INSERT INTO loan_schedule VALUES ('01077150050921 ',1,0) / INSERT INTO loan_schedule VALUES ('01077150050921 ',2,6348.36) / INSERT INTO loan_schedule VALUES ('01077300050011 ',1,0) / INSERT INTO loan_schedule VALUES ('01077300050011 ',2,23289.97) / INSERT INTO loan_schedule VALUES ('01107010000277 ',1,0) / INSERT INTO loan_schedule VALUES ('01107010000277 ',2,4550.62) / INSERT INTO loan_schedule VALUES ('01107010000288 ',1,0) / INSERT INTO loan_schedule VALUES ('01107010000288 ',2,7215.96) / INSERT INTO loan_schedule VALUES ('01107150050610 ',1,5188.12) / INSERT INTO loan_schedule VALUES ('01117110050060 ',1,0) / INSERT INTO loan_schedule VALUES ('01117110050060 ',2,23528.29) / INSERT INTO loan_schedule VALUES ('01117110050071 ',1,0) / INSERT INTO loan_schedule VALUES ('01117110050071 ',2,16469.8) / INSERT INTO loan_schedule VALUES ('01117150051071 ',1,7782.17) / INSERT INTO loan_schedule VALUES ('01117180000631 ',1,0) / INSERT INTO loan_schedule VALUES ('01117180000631 ',2,49664.37) / INSERT INTO loan_schedule VALUES ('01137110050082 ',1,0) / INSERT INTO loan_schedule VALUES ('01137110050082 ',2,47056.57) / INSERT INTO loan_schedule VALUES ('01147150052362 ',1,5875) / INSERT INTO loan_schedule VALUES ('01147150052384 ',1,0) / INSERT INTO loan_schedule VALUES ('01147150052384 ',2,10376.23) / INSERT INTO loan_schedule VALUES ('01157010001078 ',1,0) / INSERT INTO loan_schedule VALUES ('01157010001078 ',2,10764.62) / INSERT INTO loan_schedule VALUES ('01157150051316 ',1,0) / INSERT INTO loan_schedule VALUES ('01157150051316 ',2,12970.28) / INSERT INTO loan_schedule VALUES ('01157150051338 ',1,0) / INSERT INTO loan_schedule VALUES ('01157150051338 ',2,8812.5) / INSERT INTO loan_schedule VALUES ('01167150051647 ',1,2711.43) / INSERT INTO loan_schedule VALUES ('01507150051043 ',1,0) / INSERT INTO loan_schedule VALUES ('01507150051043 ',2,18158.39) / INSERT INTO loan_schedule VALUES ('01957180000928 ',1,0) / INSERT INTO loan_schedule VALUES ('01957180000928 ',2,14561.49) / INSERT INTO loan_schedule VALUES ('02007180001216 ',1,0) / INSERT INTO loan_schedule VALUES ('02007180001216 ',2,36039.68) / INSERT INTO loan_schedule VALUES ('03017180001733 ',1,0) / INSERT INTO loan_schedule VALUES ('03017180001733 ',2,25083.02) / INSERT INTO loan_schedule VALUES ('03317290050021 ',1,0) / INSERT INTO loan_schedule VALUES ('03317290050021 ',2,9833.81) / INSERT INTO loan_schedule VALUES ('03317290050040 ',1,0) / INSERT INTO loan_schedule VALUES ('03317290050040 ',2,7375.36) / INSERT INTO loan_schedule VALUES ('09997040001950 ',1,0) / INSERT INTO loan_schedule VALUES ('09997040001950 ',2,13864.94) / INSERT INTO loan_schedule VALUES ('09997120004685 ',1,0) / INSERT INTO loan_schedule VALUES ('09997120004685 ',2,3495.59) / INSERT INTO loan_schedule VALUES ('09997120004696 ',1,0) / INSERT INTO loan_schedule VALUES ('09997120004696 ',2,4339.15) / INSERT INTO loan_schedule VALUES ('09997220000893 ',1,0) / INSERT INTO loan_schedule VALUES ('09997220000893 ',2,3429.21) /
YamenHello
When there is a WHERE clause, it always comes after the FROM clause. (Joints and their conditions are part of the FROM clause).
Try this:WITH got_rnum AS ( SELECT cod_acct_no , amt_instal , ROW_NUMBER () OVER ( PARTITION BY cod_acct_no ORDER BY ctr_stage_no DESC ) AS rnum FROM loan_schedule ) SELECT m.cod_acct_no, m.amt_disbursed, m.bal_book , r.amt_instal AS high_amt_instal FROM loan_mast m JOIN got_rnum r ON r.cod_acct_no = m.cod_acct_no AND r.rnum = 1 WHERE m.cod_acct_stat = '8' ----------[this is condition is newly added to apply the same in production to fetch desired record] ;
-
best way to find the maximum value that is less than a specific value?
Hello guys,.
What is the fastest way to find a record that has value max of a field and there is a limitation to a specific value for ex:
example 1:
I want to get:create table dummy(master_id number, detail_id number, some_value varchar2(80)); insert into dummy values (1,1,'bla bla1'); insert into dummy values (1,2,'bla bla2'); insert into dummy values (1,3,'bla bla3'); insert into dummy values (2,1,'bla bla4'); insert into dummy values (2,2,'bla bla5'); insert into dummy values (2,3,'bla bla6'); insert into dummy values (2,4,'bla bla7'); commit;
And these applications give a correct result:1 3 bla bla3 2 4 bla bla7
If these solutions are enough or is there a better way?Select * from dummy d1 where detail_id = (select max(detail_id) from dummy d2 where d2.master_id = d1.master_id); OR next one which i prefered. Select * From (Select d1.* , row_number() over(partition by master_id order by detail_id desc) r from dummy d1) Where r = 1;
Edited by: elcaro on 13.Ara.2011 04:02
Edited by: elcaro on 14.Ara.2011 04:31Please try this with your new test tables:
select m.master_id, m.master_data, max(d.id) keep (dense_rank last order by data_value, d.id) d_id, max(d.master_id) keep (dense_rank last order by data_value, d.id) d_master_id, max(data_value) keep (dense_rank last order by data_value, d.id) d_data_value, max(date_data) keep (dense_rank last order by data_value, d.id) d_date_data from master_dummy m, detail_dummy d where m.master_id=d.master_id and d.date_data <= to_timestamp('04012010','ddmmyyyy') group by m.master_id, m.master_data
Published by: hm on 14.12.2011 05:18
(I added d.id column in the order by the dense_rank. clause that could make a difference when there is more than one line with the same data_value).
-
How to find the second largest in a pl/sql table
Hello friends,
I want to find the first and second maximum items in a pl/sql table.
Here's the code...
DECLARE
Max_earnings_type TYPE TABLE IS NUMBER;
max_earnings_tab max_earnings_type: = max_earnings_type();
number of v_count: = 0;
number of v_max_earnings;
Can someone give me how to find the maximum first max and second in the type of the given table.
appreciate your help.
Thank you/kumar
Published by: kumar73 on October 21, 2010 09:42kumar73 wrote:
When I tried to implement your logic in my application, I get the following error...
PL/SQL: digital or value error: NULL index key value table
What happens if the PL/SQL table has NULL values. Question is how you want to handle NULL values. You want to ignore nulls as GROUP BY do? If you want to consider NULL values, you can say if you want to order the NULLS FIRST or NULLS LAST. I guess that logical GROUP BY:
DECLARE TYPE max_earnings_type IS TABLE OF NUMBER; TYPE max_earnings_sorted_type IS TABLE OF NUMBER INDEX BY BINARY_INTEGER; max_earnings_tab max_earnings_type; max_earnings_tab_sorted max_earnings_sorted_type; BEGIN SELECT sal + comm BULK COLLECT INTO max_earnings_tab FROM emp; FOR v_i in 1..max_earnings_tab.count LOOP IF max_earnings_tab(v_i) IS NOT NULL THEN max_earnings_tab_sorted(max_earnings_tab(v_i)) := 1; END IF; END LOOP; DBMS_OUTPUT.PUT_LINE('MAX value in PL/SQL table is ' || nvl(to_char(max_earnings_tab_sorted.last),'NULL')); DBMS_OUTPUT.PUT_LINE('Second MAX value in PL/SQL table is ' || nvl(to_char(max_earnings_tab_sorted.prior(max_earnings_tab_sorted.last)),'NULL')); END; / MAX value in PL/SQL table is 2650 Second MAX value in PL/SQL table is 1900 PL/SQL procedure successfully completed. SQL> SELECT sal + comm 2 FROM emp; SAL+COMM ---------- 1900 1750 2650 1500 SAL+COMM ---------- 14 rows selected. SQL>
SY.
-
Find the Maximum using the registry to offset
Hello
I'm trying to find the maximum value of the input signal and display in the front panel. I managed to achieved this for values that are positive. but when my signal is completely negative it does not update my max.
I enclose my VI.
Thanks for your help.
Dylan
Here is a quick sketch...
-
Find the maximum numeric value to a String
Hi all
I want to find the maximum number of the string using PLSQL. How can I do this simply.
Example string: "D32X1U7".
And I want to get maximum numeric value is of this string. (7)
Thank you
Something like this:
SQL >
SQL > with input_data (select ' D32X1U7' double Str).
2 split_char AS (select substr (str, level 1) c
input_data 3
4. connect by level<=>=>
5 )
6 select max (c)
7 of split_char
8 where the regexp_like (c, ' [[: digit :]]');]])
MAX (C)
------
7
SQL >
-
How to find the value max and min for each column in a table 2d?
How to find the value max and min for each column in a table 2d?
For example, in the table max/min for the first three columns would be 45/23, 14/10, 80/67.
Thank you
Chuck,
With color on your bars, you should have enough experience to understand this.
You're a loop in the table already. Now you just need a function like table Max and min. loop. And you may need to transpose the table 2D.
Maybe you are looking for
-
How can I configure Outlook 2010 to overide icloud for calendars and Contacts?
I just bought and mini Ipad 4 and have an iphone 5 s. I decided to Setup place iCloud for my devices. Here's the thing: on my PC, I use Outlook 2010 and I love it for calendars and Contacts. I usually sync it with my iphone via itunes without any p
-
I searched and downloaded every suggestion of recovery I can find on the internet. Nothing worksIdeas: You have problems with programs Error messages Recent changes to your computer What you have already tried to solve the problem Remember - this is
-
Pavilion dv7 1245 dx boot problem
Hey everybody, Just FYI, I have a dv7-1245dx with a VISTA OS and hard drive of 320 GB. I was unable to boot my dv7 for about a week when (I think) the hard drive crashed while the computer is running. I ran the disk hard main self test and received 3
-
Hi all This may seem trivial to most of you, but I even rolled my head around the dells. I just noticed that my traffic vlan trunking on a SHIFT the evacuation for VLANs as unmarked rule. I used the switchport mode trunk and allowed the VLAN necessar
-
Hello, I use Windows Vista Home Premium and since I bought my laptop Windows Aero worked fine on it. However, recently I installed the HP printer software on my laptop and after I finished I opened a Web page explore. When I did that an error has occ