Calculate the max and sum value by weird way !!!
this code calculate the sum value without sum clause :-
DECLARE
x NUMBER;
y NUMBER := 0;
CURSOR cur_sal
IS
SELECT sal
FROM emp;
BEGIN
OPEN cur_sal;
LOOP
FETCH cur_sal
INTO x;
EXIT WHEN cur_sal%NOTFOUND;
y := y + x;
END LOOP;
CLOSE cur_sal;
DBMS_OUTPUT.put_line ('sum sal without using sum function = ' || y);
END;
and this code calculate the max value without max clause :-
DECLARE
x NUMBER;
y NUMBER := 0;
CURSOR cur_sal
IS
SELECT sal
FROM emp;
BEGIN
OPEN cur_sal;
LOOP
FETCH cur_sal
INTO x;
EXIT WHEN cur_sal%NOTFOUND;
IF (x > y)
THEN
y := x;
END IF;
END LOOP;
CLOSE cur_sal;
DBMS_OUTPUT.put_line ('max sal without using max function = ' || y);
END;
the Question is : how suppose that's happen ?
what's the secret in those codes ?
it's just new idea for me , but I don't understand !
is there any name for this way in ( Oracle® Database PL/SQL User's Guide and Reference ) ?
if not , so please anyone give me any help to understand those codes !
Secret? What secret? It slowly and inefficiently fetch each row one at a time and consecutively add them together you get a sum. What the first, horribly inefficient, cursor loop is doing is roughly the equivalent of determining how many rivets are in a bucket by dumping them on the floor and picking them up one at a time rather than weighing one, weighing all, and then doing a simple division. The second loop does the same, horribly inefficient thing, by picking up each rivet and seeing if it is bigger than the previous one.
Cursor loops are obsolete and this code is about as inefficient as you can get without using an Excel macro.
Similar Messages
-
Query Designer in BI - How to cumulate value and get the Max and Min value.
I want to create a report with query designe of BI 7r. is it possible. the data from the cube will be
Year , Exposed Quantity
1999 , 200
2000 , 100
2001 , -100
2002 , 300
2003 , - 200
2004 , 100
2005 , -200
Calculation should be - Refer the cumulative value field
Year , Exposure Quantity , Cumulative value
1999 , 200 , 200
2000 , 100 , 300
2001 , -100 , 200
2002 , 300 , 500
2003 , - 200 , 300
2004 , 100 , 400
2005 , -200 , -200
An the out put of the report should be Max value ie 500 and Min Value -200.
My question is that is it possible to do in the front end ie in the Query Designer (BI 7) If so how.
Edited by: Parakadavil Chacko Mathew on Oct 8, 2009 3:52 AMHi there,
Create 4 column,
1st will show regular values for the key figure,
2nd will show Cumulative value, in Query Designer, Just right click on the this 2nd key figure properties, calculation tab there you can check on Cumulated option, and define the calculation direction as Calculate along the Column.
3rd will show Minimum value , Just right click on the this 2nd key figure properties, calculation tab calculate single valuea as minimum.
4th will show Minimum value , Just right click on the this 2nd key figure properties, calculation tab calculate single valuea as Maximum.
Regards,
Rajdeep Rane. -
I am a rookie and need help with max and min values
Hello all, i am into this intro to java class. my assignment is to write a program that prompts the user for two integers and then prints the sum, difference, average, product , distance (absolute value of the difference) Maximum(largest of the two) and Minimum(smallest fo the two) here is my code so far
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.Math;
public class Sample4
public static void main(String[] args) throws IOException
try // attempt the following
{ // create the stream to read from
InputStreamReader istream = new InputStreamReader(System.in); // create a buffer to hold the stream
BufferedReader console = new BufferedReader(istream); // prompt the user
System.out.println("Enter a number please"); // get input as a string
String input = console.readLine(); // convert to an integer
int num1 = Integer.parseInt(input);
System.out.println("Enter a number please"); // get input as a string
String input2 = console.readLine(); // convert to an integer
int num2 = Integer.parseInt(input2);
int sum = num1 + num2; // get the sum of the two inputs
int difference = num1 - num2; // get the difference of the two inputs
int product = num1 * num2; // get the product of the two inputs
int average = sum / 2; // get the average of the two inputs
int abs = Math.abs(difference); // get the absolute value of the two inputs
// new section
// display the number
System.out.println("The total sum = " + sum);
System.out.println("The total difference = " + difference);
System.out.println("The total product = " + product);
System.out.println("The total average = " + average);
System.out.println("The total absolute value = " + abs);
} // if something breaks, catch the exception
catch (IOException e)
System.out.println(e); // displays the exception
System.exit(1); // quits the program
}what will be the right syntax or code to find the MAX and MIN values of two numbers a User Inputs, hope someone can help with this. thank you for your help.Thanks alot man, sheesh i do not know why my book
doesnt give me all the static methods. but i do really
appreciate your help. peaceA complete list of the java.lang.Math methods can be found at http://java.sun.com/j2se/1.4/docs/api/java/lang/Math.html
btw,
max(a, b) == (a > b) ? a : b
min(a, b) == (a < b) ? a : b -
Get max and min values from waveform chart
Hi all
Ive got a waveform chart and want to display the max and min value for the graph. How do i get the respective values?? Im using LabView 8.2
holla
Attachments:
Untitled 231_LV80.vi 23 KBThanks Mike
-
How to get Max and Min value entered in a DOS console?
Hi there? I wanted to get the Maximum and Minimum value that I entered in a console and displays it. This is using the java.lang.Math class and using it's method max and main. please help. thanks - new to java
Sounds like you need very basic advice: Start with the tutorials: http://java.sun.com/docs/books/tutorial/index.html
And if the algorithm is the problem:
- Make two variables that hold the current maximum and minimum value
- whenever a value is entered, compare it with the minimum, if it is smaller, set the minimum to that value
- ditto with maximum
at the end the two variables contain the maximum and minimum values. -
How can i do to see the master and text values of the Key figure 0UNIT
Hi gurus,
How can i do to see the master and text values of the Key figure 0UNIT, please step by step, i m in the key figure 0UNIT but i want to see if the UNIT for example BX = BOX, something like this is that i want to check, thanks!If you look at the unit tables, you will see the values and texts. It's in SPRO, not in RSA1. My access is limited on my system here, but the documentation says to go to t-code CUNI. I believe in that tcode you can look at all of the unit equivalencies and what each unit's text is ..... like an ea means each; KG = Kilogram; etc...
I am on an 3.x system, so in SPRO I go to BW CIG=>General Settings=>Check units of measurement.
Brian -
In Oracle 10g, what is the max number of values we can pass to 'IN' Clause
Hi,
In my SQL query i have a scenario like, i have to pass the values to 'IN' Clause dynamically from other application. I want to know what is the the max number of values i can pass to 'IN' Clause.
i have searched in many pages i seeing answers like 'may be 1000' , 'not sure'....
Could any one tell me the exact limit of IN Clause in 10g.
Thanks in Advance.
ChandranHi, Chandran,
Chandran M wrote:
In my SQL query i have a scenario like, i have to pass the values to 'IN' Clause dynamically from other application. I want to know what is the the max number of values i can pass to 'IN' Clause.
i have searched in many pages i seeing answers like 'may be 1000' , 'not sure'....Don't overlook [Dont want to know|http://forums.oracle.com/forums/thread.jspa?messageID=2683385�]. This may explain why people are reluctant to give a straight answer.
Could any one tell me the exact limit of IN Clause in 10g.1000 items such as IN (1, 2, 3, ..., 1000)
No limit on the number of sets: IN ((1), (2), (3), ...) *<=== NOT QUITE!* See below
No limit in sub-queries: IN (SELECT ...)
Edited by: Frank Kulash on Jun 3, 2009 9:43 AM
The limit of 1000 applies to sets of single items: (x) IN ((1), (2), (3), ...)
There is no limit if the sets contain two or more items: (x, 0) IN ((1,0), (2,0), (3,0), ...)
Thanks to Michaels for pointing this out.
Edited by: Frank Kulash on Jun 3, 2009 10:22 AM
Fixed link -
Where could we find the CT and PT values for Particular Device ???
I 'm facing a scenario in a report i need to place a field device number and assosiated CT's and PT's .
where could we find the CT and PT values for Particular Device ??? basically im MM consultant we don't ahave DM consultant please help with this issue???
means actually i got the table and field details for transformation ratio (or) CT/PT ratio
ETYP_UEBERVER. from the screen EG03 , t-code
but im not sure this is the exact field that i require ....
can any one help .... i will be very thankfull to your solution inadvance....The transformation ratio are the attributes of a "Winding Group". Find winding group of a device and then you'll get the desired information.
-
How to avoid the Amount and Date values for VOID Cheques
Hi All,
I had created a two window i.e For Amount and Date. If I process the cheque the Amount value and Date should not trigger for VOID CHEQUES.
Can any one tel me how to avoid the Amount and Date values for VOID Cheques
Your help will be greatly appreciated.
Regards
YathishHi,
I dont know which tablel you are referring to, is it PAYR table and the field VOIDR?
If a cheque is voided, it would have a reason and it is stored in VOIDR field of this PAYR table.
Check if the field VOIDR is filled, if it is filled, do not print the amount and date.
Regards
Subramanian -
I purchased the app Cake Mania to the Max and after 67,000+ points, the games has locked up. I have tried to restart the game on my IPAD and it brings the game up but when you get to the play command, nothing happens. Anyone else have this problem? I contacted Digital Chocolate but have had no rsponse back from them. I paid for this game and this is the way they take care of their purchasers. Any ideas??
Hey briannagrace96,
Welcome to Apple Support Communities! I'd check out the following article, it looks like it applies to your situation:
iPod: Appears in Windows but not in iTunes
http://support.apple.com/kb/ts1363
You'll want to go through the following troubleshooting steps, and for more detail on each step follow the link to the article above:
Try the iPod troubleshooting assistant:
If you have not already done so, try the steps in the iPod Troubleshooting Assistant (choose your iPod model from the list).
If the issue remains after following your iPod's troubleshooting assistant, follow the steps below to continue troubleshooting your issue.
Restart the iPod Service
Restart the Apple Mobile Device Service
Empty your Temp directory and restart
Verify that the Apple Mobile Device USB Driver is installed
Change your iPod's drive letter
Remove and reinstall iTunes
Disable conflicting System Services and Startup Items
Update, Reconfigure, Disable, or Remove Security Software
Deleting damaged or incorrect registry keys
Take care,
David -
I want to select a specific rectangular position from intensity graph to extract the x and y values
I want to select specfic rectangular postion from an intensity graph to extract the X and Y values at that specific position.
Is this possible using LabVIEW?
@nkHi nk,
Is this possible using LabVIEW?
Yes.
I want to select specfic rectangular postion from an intensity graph to extract the X and Y values at that specific position.
Just select the positions! What's your problem in doing so?
Btw. when you select positions you already know their XY values!? I don't get the point of your task...
Best regards,
GerdW
CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
Kudos are welcome -
Error 13641 - The Subnet prefix must be between the starting and ending values
Hi All,
I can honestly say hand on heart that this is the first time I have ever asked for help in a forum in over 15 years but this is doing my head in..
I have a Sys Center 2012 R2 deployment.. VMM R2 up to RU3, Edge Cluster (2 hosts), Management Cluster (2 hosts), 2 x Production Compute Clusters (total of 20 hosts). I have a HA Network Virt Gateway deployed on the edge cluster.
All Hosts have the new DHCP install done and the RU3 SQL patch is completed as outlined in deployment manual.
Everything had been running fine for some time after RU3 update... I am experiencing an issue whereby I get the following error anytime I try and attach a NVGRE VM network to a VM, or when I try and migrate a VM with a NVGRE network attached to another
host.
Error (13641)
The specified subnet prefix must be between the starting and ending values for the range.
Starting value: 4
Ending value: 30
Recommended Action
Specify a suitable subnet prefix.
All subnets in the entire network are /24's so prefix isn't an issue.
I can successfully attach a standard vm network but get the above error when working with NVRGE networks..
Further to this, if I restart VMM the DHCP function to VM's with NVGRE networks doesn't get picked up until I trigger a change in config on the VM, then it will get IP and function as expected.
I have checked all logs, there aren't any errors that I can see.
get-netvirtualizationlookuprecord throws out VM's and PA's as expected, but again not until I manually interfere with the VM in question.
Have any of you come across this before?? I want to check before I go rebuilding the PA network entirely and having to cleanup all existing VM networks to do it..
Any help or guidance would be appreciated..
Cheers
NathanI have seen this message before, "specify a suitable subnet prefix".
In my case, the NVGRE policies were out of sync due to HW issues on several hosts.
Here's some steps in order to troubleshoot/fix:
run the following cmdlet: Get-SCVMHost | Read-SCVMhost -RunAsynchronously
Check for any errors in the job log that refers to "Network Virtualization".
If this doesn't help, a recycle of the VMM Management server should do a "hard refresh" of the NVGRE policies, and it might include a reboot of the nvgre hosts too.
This solved the case in my situation.
-kn
Kristian (Virtualization and some coffee: http://kristiannese.blogspot.com ) -
my friend gave me her ipod about 2 years ago. neither of us know the passcode and now we have no way to link it to the original itunes account. is there a way i can reset it so i can use it?
I have tried plugging it in and holding the sleep/wake button and home button at same time and all it does is gives me the "slide to power off" option. Is there anything I can do??? Please Help!
Message was edited by: Unordinary92Try DFU mode and then restore
How to put iPod touch / iPhone into DFU mode « Karthik's scribblings
Or try using this program to place the iPod in recovery mode
RecBoot: Easy Way to Put iPhone into Recovery Mode
- Next try the manual install method of:
iDevice Troubleshooting 101 :: iPhone, iPad, iPod touch
Place the iPod in recovery mode after the firmware download is complete and then restore using the instructions in the article. Sometimes recovery mode timeouts and returns to disabled before the firmware download is complete.
- Then try on another computer -
I get a msg that the phoen wasn't backed up to the cloud and i won't go way. It also won't let me log in or turn off the phone.
Have you tried a reset ? Press and hold both the sleep and home buttons for about 10 to 15 seconds (ignore the red slider if it appears), after which the Apple logo should appear - you won't lose any content, it's the iPad equivalent of a reboot. You can then do a backup
-
How to Get the min,max and original values in a single query
Hi,
I have a task where in i have to the min , max and the original values of a data set .
I have the data like below and i want the target as well as mentioned below
SOURCE
DATASOURCE
INTEGRATIONID
SLOT_DATE
SLOT1
SLOT2
SLOT3
SLOT4
SLOT5
SLOT6
SLOT7
SLOT8
SLOT9
SLOT10
1
101
201111
100
100
200
100
100
100
300
300
300
300
1
101
2011112
200
200
200
200
100
100
100
100
200
300
TARGET
DATASOURCE
INTEGRATIONID
SLOT_DATE
SLOT_VALUE
SLOT MIN
SLOT_MAX
SLOT NUMBER
1
101
201111
100
1
2
SLOT1
1
101
201111
100
1
2
SLOT2
1
101
201111
200
3
3
SLOT3
1
101
201111
100
4
6
SLOT4
1
101
201111
100
4
6
SLOT5
1
101
201111
100
4
6
SLOT6
1
101
201111
300
7
10
SLOT7
1
101
201111
300
7
10
SLOT8
1
101
201111
300
7
10
SLOT9
1
101
201111
300
7
10
SLOT10
1
101
2011112
200
1
4
SLOT1
1
101
2011112
200
1
4
SLOT2
1
101
2011112
200
1
4
SLOT3
1
101
2011112
200
1
4
SLOT4
1
101
2011112
100
5
8
SLOT5
1
101
2011112
100
5
8
SLOT6
1
101
2011112
100
5
8
SLOT7
1
101
2011112
100
5
8
SLOT8
1
101
2011112
200
9
9
SLOT9
1
101
2011112
300
10
10
SLOT10
e
so basically i would first denormalize the data using the pivot column and then use min and max to get the slot_start and slot_end.
But then i
can get the min and max ... but not the orignal values as well.
Any thoughts would be appreciated.
ThanksIf you want to end up with one row per slot per datasource etc, and you want the min and max slots that have the same value as the current slot, then you probably need to be using analytic functions, like:
with t as
(SELECT 1 datasource,101 INTEGRATIONID, 201111 slotdate, 100 SLOT1, 100 SLOT2, 200 slot3, 100 slot4, 100 slot5, 100 slot6, 300 slot7, 300 slot8, 300 slot9, 300 slot10 FROM DUAL union all
SELECT 1, 101, 2011112, 200, 200, 200, 200, 100, 100, 100, 100, 200, 300 FROM DUAL),
UNPIVOTED AS
(SELECT DATASOURCE,INTEGRATIONID,SLOTDATE,1 SLOT,SLOT1 SLOT_VALUE
FROM T
UNION ALL
SELECT DATASOURCE,INTEGRATIONID,SLOTDATE,2 SLOT,SLOT2
FROM T
UNION ALL
SELECT DATASOURCE,INTEGRATIONID,SLOTDATE,3 SLOT,SLOT3
FROM T
UNION ALL
SELECT DATASOURCE,INTEGRATIONID,SLOTDATE,4 SLOT,SLOT4
FROM T
UNION ALL
SELECT DATASOURCE,INTEGRATIONID,SLOTDATE,5 SLOT,SLOT5
FROM T
UNION ALL
SELECT DATASOURCE,INTEGRATIONID,SLOTDATE,6 SLOT,SLOT6
FROM T
UNION ALL
SELECT DATASOURCE,INTEGRATIONID,SLOTDATE,7 SLOT,SLOT7
FROM T
UNION ALL
SELECT DATASOURCE,INTEGRATIONID,SLOTDATE,8 SLOT,SLOT8
FROM T
UNION ALL
SELECT DATASOURCE,INTEGRATIONID,SLOTDATE,9 SLOT,SLOT9
FROM T
UNION ALL
SELECT DATASOURCE,INTEGRATIONID,SLOTDATE,10 SLOT,SLOT10
FROM T)
select DATASOURCE,INTEGRATIONID,SLOTDATE,slot,slot_value,min(slot) OVER (partition by datasource,integrationid,slotdate,rn) minslot,
max(slot) OVER (partition by datasource,integrationid,slotdate,rn) maxslot
FROM
select DATASOURCE,INTEGRATIONID,SLOTDATE,max(rn) over (partition by datasource,integrationid,slotdate order by slot) rn,slot,slot_value
FROM
(SELECT DATASOURCE,INTEGRATIONID,SLOTDATE,slot,slot_value,
case when row_number() over (partition by datasource,integrationid,slotdate order by slot) = 1 or
lag(slot_value) over (partition by datasource,integrationid,slotdate order by slot) <> slot_value
then row_number() over (partition by datasource,integrationid,slotdate order by slot)
ELSE null
END rn
from unpivoted
order by DATASOURCE,INTEGRATIONID,SLOTDATE,slot
Maybe you are looking for
-
BPC 10.0 NW Comment Length
Hi all, I'm going around in circles here and not finding the cause, so I'm hoping you'll be able to tell me what I'm missing! We're running BPC 10.0 NW SAPK-80102INCPMBPC and we have some templates that are set up to save more than 1000 characters in
-
Adding multiple swf files to Dreamweaver
I'm trying to upload multiple .swf files to my website with no luck. I've done this with previous versions of Dreamweaver but with CS3 I'm finding it won't happen. I've done the Insert -> Media -> Flash action as before and exported my files to be re
-
Images showing in wrong place in IE put right in Fire fox
Hi, I have designed a page for my clubs new website - I have probably done this all wrong as I am a complete novice. I have set tha images to align 'right' but in IE they dont yet do in Firefox The webpage is www.thevillagers.co.uk/sponsors.html I ca
-
My text messages are not being delivered
MY text messages are not being delivered. Keep coming back with the red saying "Not Delivered". Anyone know why this all of a sudden started happening and how to fix it?
-
Non-backlit screen, help?
I'm sort of getting tired of taking this 'Book apart and reassembling- I have the infamous missing backlight problem: the display has images but no illumination. I have replaced the inverter twice with the same results, am wondering what other source