calculate the balance
A temp table has the following values. I have trouble finding a way to calculate the balance. I think the problem for me, it's the setting value can be either + or-. Can you help me? can you help me?inv Date code comments amt applied balance
T090 08/23/2005 120
T090 10/02/2005 A inv adjust -90
T090 04/25/2006 C chk 123 30
B080 10/01/2007 240
B080 12/21/2007 C chk 221 120
B090 02/02/2008 A inv adjust 20
B091 03/06/2011 200
B091 03/23/2011 A inv adjsut -200
here = > see balance column calculationinv Date code comments amt applied balance
T090 08/23/2005 120
T090 10/02/2005 A inv adjust -90 30
T090 04/25/2006 C chk 123 30 0
B080 10/01/2007 240
B080 12/21/2007 C chk 221 120 120
B080 02/02/2008 A inv adjust 20 100
B091 02/06 200
B091 03/23/2011 A inv adjsut -200 0
Zen
Hi, Zen,
Did you see my last post?
Frank Kulash wrote:
...
I hope that answers your question.
If not, post a small example of data (CREATE TABLE and only relevant columns, INSERT statements) for all tables and also post the results desired from these data.
Explain, using specific examples, how you get these results from these data.
Always tell what version of Oracle you are using.
Looks like you need to change the analytical ORDER BY clause to remove the links.
Tags: Database
Similar Questions
-
calculate the balance depends on the previous record result
Hello
I have a requirement like calculating the balance depends on the previous record result. but I'm unable to accomplish by using select statement.
Sample data: WITH T AS (SELECT 10 AMOUNT, 0.2 PERCENT FROM DUAL UNION ALL SELECT 11 AMOUNT, 0.3 PERCENT FROM DUAL UNION ALL SELECT 12 AMOUNT, 0.3 PERCENT FROM DUAL UNION ALL SELECT 13 AMOUNT, 0.3 PERCENT FROM DUAL UNION ALL SELECT 14 AMOUNT, 0.3 PERCENT FROM DUAL )
process: 10(AMOUNT) * 0.2(PERCENT) = 2 11 - 2(Result of previous calculation) = 9 12 - 9(Result of previous calculation) = 3 13 -3(Result of previous calculation) = 10 14 - 10(Result of previous calculation) = 4;
Please, help me build the select statement.required output. AMOUNT RESULT 10 2 11 9 12 3 13 10 14 4
There is no order in the lines of the relational table. Only ORDER BY guarantees the order. So, even if the AMOUNT is increasing in your sample, I guess in life real amounts are in no particular order. If Yes, you need another column indicating the order of the lines:
WITH T AS ( SELECT 1 ID, 10 AMOUNT, 0.2 PERCENT FROM DUAL UNION ALL SELECT 2 ID, 11 AMOUNT, 0.3 PERCENT FROM DUAL UNION ALL SELECT 3 ID, 12 AMOUNT, 0.3 PERCENT FROM DUAL UNION ALL SELECT 4 ID, 13 AMOUNT, 0.3 PERCENT FROM DUAL UNION ALL SELECT 5 ID, 14 AMOUNT, 0.3 PERCENT FROM DUAL ) SELECT AMOUNT, RESULT FROM T MODEL DIMENSION BY(ID) MEASURES(AMOUNT,AMOUNT RESULT,PERCENT) RULES( RESULT[1] = RESULT[1] * PERCENT[1], RESULT[ID > 1] ORDER BY ID = RESULT[CV()] - RESULT[CV() - 1] ) ORDER BY ID / AMOUNT RESULT ---------- ---------- 10 2 11 9 12 3 13 10 14 4 SQL>
If the AMOUNT is still growing:
WITH T AS ( SELECT 10 AMOUNT, 0.2 PERCENT FROM DUAL UNION ALL SELECT 11 AMOUNT, 0.3 PERCENT FROM DUAL UNION ALL SELECT 12 AMOUNT, 0.3 PERCENT FROM DUAL UNION ALL SELECT 13 AMOUNT, 0.3 PERCENT FROM DUAL UNION ALL SELECT 14 AMOUNT, 0.3 PERCENT FROM DUAL ) SELECT AMOUNT, RESULT FROM T MODEL DIMENSION BY(ROW_NUMBER() OVER(ORDER BY AMOUNT) ID) MEASURES(AMOUNT,AMOUNT RESULT,PERCENT) RULES( RESULT[1] = RESULT[1] * PERCENT[1], RESULT[ID > 1] ORDER BY ID = RESULT[CV()] - RESULT[CV() - 1] ) ORDER BY ID / AMOUNT RESULT ---------- ---------- 10 2 11 9 12 3 13 10 14 4 SQL>
SY.
-
Calculate the balance between income and expenses
Hi, my problem is explained in picture below. How to perform calculations that include the result of the previous row in the next. Etc.
Can help you with this. I can attach a form if necessary.
Thank you
Using the FormCalc language will facilitate...
In your field of balance, you should check if its index is greater than 0, if it is, then you should use the balance before him and add it to the current balance.
If ($. parent.index > 0) then
$.rawValue = income - expenses + $.resolveNode (Concat ("Table1.Row1 [", $. "]")) parent.index - 1, "]")). Balance
on the other
$.rawValue = revenue - expenses
endif
It must be something like that... change the names to use the right reference_syntax
-
Case: View the balance of the average customer for each area code.
Hi again together. As a C++ / VB programmer, I used by using a control specified structures like for loops and while loops and use predefined variables to solve my problems. I have a little trouble to adapt to the SQL paradigm, which really does contain a few key words and in built functions.
I had to have some exercises to do by my tutor at the University, and I have a big enough problem with this one. I to recover the balance of the average customer of a 'customer' entity, but I have to do for each area code, not as a whole. When I look at this problem, I immediately think of loops, conditional check, a variable of integer type to control the loop and possibly a table or a vector data type to store the results. SQL is rather simple, and its simplicity is actually causing me problems, ironically.
Here is the "Customer" entity which I am to get directions:
I was able to order the customer balances by their area code and to calculate the balances of customers on average as a whole, but as I said I had difficulties to calculate an average of customer balances exactly their area code and do it for all the codes present.CREATE TABLE CUSTOMER ( CUS_CODE NUMERIC(6) CONSTRAINT CUSTOMER_PK PRIMARY KEY, CUS_LNAME varchar(15) NOT NULL, CUS_FNAME varchar(15) NOT NULL, CUS_INITIAL CHAR(1), CUS_AREACODE VARCHAR(3) DEFAULT '02' NOT NULL CHECK(CUS_AREACODE IN ('03','07','08')), CUS_PHONE VARCHAR(8) NOT NULL, CUS_BALANCE NUMERIC(9,2) DEFAULT 0.00 );
Any help / example code would be much appreciated.OK, so you will understand how to get the average on all clients in SQL, not true? Something like
SELECT AVG(cus_balance) avg_balance FROM customer
If you want to get the average balance by another column, you simply group this column, i.e.
SELECT cus_areacode, AVG(cus_balance) avg_balance FROM customer GROUP BY cus_areacode
This essentially tells Oracle to group all data by area code before you run the aggregate function AVG on the cus_balance for each of these groups.
Justin
-
Calculate the average per slot?
Hi Chaps,
I am a beginner on numbers (almost everything on Mac I would say) and I need help to calculate average values.
These are calculated values (column 2) taken on a specific time of the day (column 1).
I managed to create a third using a built-in function to get the time slot (column 3).14:58:42
235
14
14:59:42
274
14
15:00:50
7937
15
15:01:55
5157
15
16:02:57
1822
16
16:03:57
207
16
Can please somebody see me step by step how to calculate the average by time slot as below?
14
254,5
15
6547
16
1014,5
Kind regards
Stone
This can help you
Assuming you data in a table named 'Data' and the information is summarised in another table (right) named "Summary".
Select cell B1 in the summary table and then type (or copy and paste from here):
= SUMIF(Data::C,a1,Data::B) ÷COUNTIF (Data::C, a1)
shortcut for this is:
B1 = SUMIF(Data::C,a1,Data::B) ÷COUNTIF (Data::C, a1)
Select cell B1, copy
Select column B, paste
-
Hello
I want you to help because the phone ask me for becoming a frequent and annoying password to calculate the icloud, and I do not know because I bought a phone from someone else is not new Hama is on the phone (*) No. account. IMEI (*) Please help me soon thank you
< post branched out by host >
< personal information under the direction of the host >
Robert Odamat says:
Hello
I want you to help because the phone ask me for becoming a frequent and annoying password to calculate the icloud, and I do not know because I bought a phone from someone else is not new Hama is on the phone (*) No. account. IMEI (*) Please help me soon thank you
< post branched out by host >
< personal information under the direction of the host >
Find my iPhone Activation Lock - Apple Support
There is nothing you can do to get around activation icloud blocking without recovering the former owners information.
Communicate with the person that you bought the phone.
-
Lets say I got a $10 gift card balance and I want to buy something will be only charged debit card 10 cause of $20 s $ of the balance of the gift card?
Unless it's a gift card or otherwise indicated, the debit card will be charged $10 plus tax on this item.
(143858)
-
I bought a gift card a while and now I don't have the balance for her and when I try to buy I can not because I already bought it. Help, please. If I can't do my 15 birthday money are wasted. He said as I already had a gift card in my account, but somehow everything is over now when I was not yet buy anything!
A gift card is redeemable only once, it is useless to try to buy it back again.
To see what, if any, balance you have left on the account you share you: see your credit balance - Apple Support iTunes
To see what you bought on the account and therefore potentially used some/all of it: see your purchase history in iTunes on Mac or PC - Apple Support store
-
Will the 'flights climbed' work and calculate the altitude of an aircraft?
I'm going on vacation soon and everything I just want to know my iPhone 6s will calculate the flights climbed when the plane is in the Air?
You will be on a plane with steps?
-
How to calculate the hours between two dates by the numbers
If I update 09:00 start time 17:00 end time of shift in C3 and B3, how to use a D3 formula to calculate the number of hours between the two? Then I can just copy down the lines for nth years...
It is a spreadsheet of the part-time staff payroll.
I'm sure that a lot of people out there have done that.
Help, please.
Thank you.
Eddie
What program of worksheet that you are using? Since you have a newer iMac running El Capitan, I can safely assume that you use NOT AppleWorks, which is a Power PC application that can run on any OS newer than the snow leopard, OS X 10.6.8.
If you use numbers, try to repost your question in numbers for Mac forum. If you use Microsoft Excel, try posting in the Microsoft forums. LibreOffice also has community support.
-
How to calculate the difference between two times by the NUMBERS
I'm so bothered by the fact that I can't understand that.
Cell B2 - 08:00
Cell C2 - 10:50
(How can cell D2 - I get this cell to calculate the difference and say 02:50?)
I know it's probably one of the most basic operations, but for the life of me I can't understand it. The cells B2 and C2 are formatted for a 24-hour clock. But if I tell the system to just subtract the two, I get "0,118. Everything I find on the forum search goes beyond what I need. Can someone help me?
Thank you
Hi sapirs,
Departure and arrival of the cells are in Date and time with Date format: no and time: 24-hour clock.
Formula in D2 (fill down)
= C2−B2
The results become a duration format, but under automatic (numbers automatically worth this format)
If you wish, you can change the cells of lasting results.
What Data Format have your result cells?
Kind regards
Ian.
-
How to check the balance on the gift card itunes
How to check the balance on the gift card itunes
Redeem it
-
can I close an iTunes account and send the balance of my credit to another account?
can I close an iTunes account and send the balance of my credit to another account?
You cannot do one of these yourself. Click here and ask the staff of the iTunes Store for the balance on the card. they will do only that if none of it has been spent. Once done, stop using this account.
(137472)
-
How to calculate the execution time of a SCTL in FPGA VI?
Hello
Can someone guide me that how to calculate the execution time of a SCTL for an iteration in the FPGA VI?
Thank you and best regards,
Rashid
Hello r,.
A SCTL will always run in a beat the clock it has been linked to. So, if you use a 40 MHz clock, this loop will run in 25 ns. If the code cannot complete in that, or if it requires two graduations of the watch to do the calculation, your code does not compile, then you have the guarantee that this will always be how long it takes this piece of code to run.
-
I have the datasheet of a NTC (thermistor negative Coefficient) and I want to calculate the most approximate equation
that describes its behavior. The table has values of temperature and resistance. If the resistance of the NTC varies according to the temperature it detects. I tried the following:
-Excel: polynomial adjustment
-Maple: polynomial adjustment
-LabVIEW: Polynomial Fit.vi
I've been doing equations with a not very good approximate parameteres. I suspect that this method 'Polynomial FIT' it is not the best method for this type of data/equation (being a non-linear equation).
So is - that someone has used the non-linear Fit.vi matching the behavior of a dataset object? If so, can you explain how this VI... I would really appreciate it.
Thanks in advance and I will wait for your reply.
Maybe you are looking for
-
Ads pop up on the new MacBook Air. Very frustrating.
I just plug a new MacBook Air on the weekend. I used help migration to transfer my files from one to the other. I think that it might cause a problem because whenever I try to use Safari and click a link, or anywhere on a page, it opens a new tab for
-
I can't find anything under Tools > options for helping me change my tabs. The "tabs" section has only a few boxes. Where can I configure what a new tab opens up to?
-
Satellite A30 much HARD disk activity when you connect
Help! My A30 makes disk workloads when resume after power off tension/setting Hibernate / standby that makes it really, really slow to do anything. Sometimes, it can take up to 15 minutes before any useful work can be done. What it does and how it ca
-
Photo Gallery functions lost after system reload
I am running Vista Home Basic and had to recharge the system due to virus problem. After charging, some functions of Windows Photo Gallery went specifically to adjust exposure to the problems of shadows and highlight. I loaded all the updates that ar
-
Specifications of the system 'not available '.
Randomly, I decided today to go look at my laptop specs, I compared the configuration required for the games, and when I went to my computer system properties section, I met a problem: the categories of installed memory (RAM) and processor were not t