To calaculate running balance in an sql
how to calaculate running balance in an sql
my values like
Decription debit credit balance
Opening 10000 10000
id-1 1000 11000
id-2 500 10500
id-3 1500 12000
etc
Please help me for this sql
I want running balance for seperate a/c alsoYou have been supplied with the resorces to do this yourself (with a little application on your part), you have also been supplied with one bespoke solution to your problems. A very small alteration to the existing code that you were spoon fed, will solve your issue. Several of the pages on the link that I posted will perform exactly what you need to do, with nothing more than table and column name changes. Have a read of at least one, you will be able to get the answer on your own. And if not, post back with what you attempted and we will help you understand better.
Similar Messages
-
SQL statement running balance query with previous balance taken into account
Hi Guys
I have a SQL statement which caclulates the running balance
for a list of transactions in a transactions table. This SQL
statement is as follows:
SELECT transID, debit, credit,
(SELECT SUM(debit-credit)
FROM transactions as D1
WHERE D1.transID <= D0.transID) AS balance
FROM transactions AS D0
The only problem I'm having is that I have to display
transactions between a particular date range. I have for eg.
transID, transDate, debit, credit fields in my db.
However the problem I'm having is that when the transaction
records are pulled out for the specified date range the balances
are only calculated for those records. I need someway of having a
balance b/f (brought forward) so that the selected records use that
as a 'starting' balance and then calculate the running balance as
normal.
Any easy solutions?
Many, many thanks for your help in advance.
All the best
WesleyYou'd need to determine the b/f then apply it against the
transaction records when they are pulled for a date range. So if
the date range is
Feb 1st, 2009 -> Feb 28th, 2009
You'd need to also get the previous balance in a separate
query, then use it to correctly display the running balance when
you output the date range.
I suppose a simpler way involving a little more DB work (and
possibly lots of coding) is to store the current balance as well
with each transaction; then when performing a date range you'd have
the balance as well and not have to calculate it on the fly. -
Formula Column in Matrix Report (Running Balance)
Hi all. I hope somebody can help me.
I am working on a matrix report using multi-query data models. The report has 2 groups in the horizontal axis and 3 groups in the vertical axis. The intersection is not just a single row but may consist of multiple rows.
My problem is this. I want to create a column in the intersection which is obtained by using a column value from the lowest group in the vertical axis and a summary column obtained from the rows of the intersection.
Here's what my report looks like:
2002 (accross)
2002(down) january february (accross)
January (down) payments balance payments balance
loan #1 10,000 500 9,000 200 8,800
500
loan #2 5,000 100 4,900 200 4,700
February
loan #3 3,500 0 3,500 50 3,450
loan #4 4,200 0 4,200 0 4,200
As you can see, the loans are grouped by month and year. And the payments are grouped for the month and year too.
The data model is :
For Query 1 (Vertical Axis),
1st group - Loan Yr
2nd group - Loan Mo
3rd group - Loan # and amount
For Query 2 (Horizontal Axis)
1st group - Payment Yr
2nd group - Payment Mo
Intersection Group - Payment Amount
My problem actually is how to compute for the running balance of the loan for each month in the horizontal axis. Ive already created a cross product summary to get the running total of the payments made for the month. I tried creating a formula column to for the running balance by subtracting it from the loan amount but i get the error "incompatible frequency"
I hope i have described my problem well and thanks for the helpThe problem is that you're trying to reference dimension columns(loan Amount) in the calculation of matrix cell values. You can only reference other matrix cell values or cross product columns (summary, formula, placeholders) when calculating matrix cell values. Try moving the (loan Amount) column down to the matrix cell - something like:
For Query 1 (Vertical Axis),
1st group - G_LoanYear(LoanYr)
2nd group - G_LoanMonth(LoanMo)
3rd group - G_LoanNumber(Loan#)
For Query 2 (Horizontal Axis)
1st group - G_PaymentYear(PaymentYr)
2nd group - G_PaymentMonth(PaymentMo)
Intersecion /Detail Group - G_Details(PaymentAmount, LoanAmount)
Then create the following Matrix summary columns:
A running summary - CS_Payments:
- Product Order: G_LoanYear G_LoanMonth G_LoanNumber G_PaymentYear G_PaymentMonth
- Source: PaymentAmount
- Function: Sum
- Reset At: G_LoanNumber
The total amount per loan - CS_TotalPayment:
- Product Order: G_LoanYear G_LoanMonth G_LoanNumber
- Source: LoanAmount
- Function: First
- Reset At: G_LoanNumber
The value of the loan after each payment - CF_Countdown:
- Product Order: G_LoanYear G_LoanMonth G_LoanNumber G_PaymentYear G_PaymentMonth
- PL/SQL Formula:
function CF_CountdownFormula return Number is
begin
return(:CS_TotalPayment - :CS_Payments);
end;
You should then be able to display "CF_Payments" and "CF_Countdown" in the matrix cell to show how much has been paid and how much is still owed.
You can still have another "loan amount" as a dimension column - you just don't need to use it when calculating the values in the cell. -
Formula Columnn in Matrix Report (Running Balance)
Hi all. I hope somebody can help me.
I am working on a matrix report using multi-query data models. The report has 2 groups in the horizontal axis and 3 groups in the vertical axis. The intersection is not just a single row but may consist of multiple rows.
My problem is this. I want to create a column in the intersection which is obtained by using a column value from the lowest group in the vertical axis and a summary column obtained from the rows of the intersection.
Here's what my report looks like:
2002 (accross) 2003
januar february (accross
payments balance paymenst balance
2002 (down)
Januar (down)
Loan#1 10,000 500 9000 200 8800
500
Loan#2 5000 100 4900 200 4700
February
Loan#3 3500 0 3500 50 3450
Loan#4 4200 0 4200 0 4200
As you can see, the loans are grouped by month and year. And the payments are grouped for the month and year too.
The data model is :
For Query 1 (Vertical Axis),
1st group - Loan Yr
2nd group - Loan Mo
3rd group - Loan # and amount
For Query 2 (Horizontal Axis)
1st group - Payment Yr
2nd group - Payment Mo
Intersecion /Detail Group - Payment Amount
My problem actually is how to compute for the running balance of the loan for each month in the horizontal axis. Ive already created a cross product summary to get the running total of the payments made for the month. I tried creating a formula column to for the running balance by subtracting it from the loan amount but i get the error "incompatible frequency"
I hope i have described my problem well and thanks for the helpThe problem is that you're trying to reference dimension columns(loan Amount) in the calculation of matrix cell values. You can only reference other matrix cell values or cross product columns (summary, formula, placeholders) when calculating matrix cell values. Try moving the (loan Amount) column down to the matrix cell - something like:
For Query 1 (Vertical Axis),
1st group - G_LoanYear(LoanYr)
2nd group - G_LoanMonth(LoanMo)
3rd group - G_LoanNumber(Loan#)
For Query 2 (Horizontal Axis)
1st group - G_PaymentYear(PaymentYr)
2nd group - G_PaymentMonth(PaymentMo)
Intersecion /Detail Group - G_Details(PaymentAmount, LoanAmount)
Then create the following Matrix summary columns:
A running summary - CS_Payments:
- Product Order: G_LoanYear G_LoanMonth G_LoanNumber G_PaymentYear G_PaymentMonth
- Source: PaymentAmount
- Function: Sum
- Reset At: G_LoanNumber
The total amount per loan - CS_TotalPayment:
- Product Order: G_LoanYear G_LoanMonth G_LoanNumber
- Source: LoanAmount
- Function: First
- Reset At: G_LoanNumber
The value of the loan after each payment - CF_Countdown:
- Product Order: G_LoanYear G_LoanMonth G_LoanNumber G_PaymentYear G_PaymentMonth
- PL/SQL Formula:
function CF_CountdownFormula return Number is
begin
return(:CS_TotalPayment - :CS_Payments);
end;
You should then be able to display "CF_Payments" and "CF_Countdown" in the matrix cell to show how much has been paid and how much is still owed.
You can still have another "loan amount" as a dimension column - you just don't need to use it when calculating the values in the cell. -
How to calculate running balance
can we calculate running balance in
discoverer 3.1.36
thanx in anticipationHi Saloni,
to get the debit and credit you would be using a variable 0I_FPER(Fiscal year / period), which is a user entry interval variable.
now to get the opening balance you will have to create a customer exit valiable and the low value of 0I_FPER will have to popuplated by writied the code for the customer exit valiable. you will have to restrict the key figure DEB_CRE_LC for this customer exit variable with the operand as less than(< Fiscal Year /Period from 0I_FPER)).
If the above was useful please assign reward points.
Regards
Venkata Devaraj -
How to get a running balance on a report
How do I get a running balance for one customer. Please look at the data set as a example and advise.
Customer A Apples
1.00 Paid
Customer A Pears
2.00 Paid
Customer A Oranges
2.50 Open
Balance 2.50
What expression am I to use in report builder
ThanksHi,
Here is the example for getting running Value:
http://gerryhubi.wordpress.com/2010/03/16/ssrs-tips-runningvalue/
SSRS Tips – RunningValue
Posted on March
16, 2010by gerryhu2000
Running value is a very generic and useful function. All
the 3 parameters can be manipulated for different purpose.
· Expression
the target on which the aggregation is applied. Most of the time it’s the column name in a dataset, or a combination of a few columns, e.g. “Group1 & Group2”.
· Function
Aggregate functions, and the most often used functions include
Avg
Returns the average of all non-null numeric values specified by the expression
Count
Returns a count of non-null values specified by the expression
CountDistinct
Returns a count of all distinct non-null values specified by the expression
Max
Returns the maximum value of all non-null numeric values specified by the expression.
You can use this for specifying a chart axis maximum value to control the scale.
Min
Returns the minimum value of all non-null numeric values specified by the expression.
You can use this for specifying a chart axis minimum value to control the scale.
Sum
Returns the sum of all the non-null numeric values specified by the expression
· Scope
The scope can be dataset, table or table groups.
The sample report below shows some applications of RunningValue. The dataset uses this query
SELECT Company, Product, InvoiceNumber, InvoiceAmount from InvoiceTable
The table (SSRS table control) is configured to have 2 groups, “gCompany” and “gProduct”.
Here is a report featured with Running Value tips
Alternate
color for Product Group
Normally the “green-bar” (green background color for alternate rows) is implemented by setting
the back ground color of the detail row to
=IIF(RowNumber(Nothing)
Mod 2,"Green","White")
To set color for alternate groups, use the expression below for background color
=IIF(RunningValue(Fields!Product.Value,CountDistinct,Nothing)
Mod 2, "LightBlue", "White")
The RunningValue function works like a counter/index for the product group.
Running
Sum value
Cumulative sum is calculated in this expression:
=RunningValue(Fields!Amount.Value,
SUM, Nothing)
“Scope = Nothing” means the outermost data region. And for Running Sum by Company or Product,
the scope if set to the corresponding group name.
=RunningValue(Fields!Amount.Value,
SUM, “gCompany”) or
=RunningValue(Fields!Amount.Value,
SUM, “gProduct”)
Group
Running Number
The summary table uses the same dataset as the details table. Normally the row number uses the
function
= RowNumber(“table1”)
For this case, the row number is using the CountDistinct function. The expression is
=RunningValue ( Fields!Company.Value +
Fields!Product.Value,
CountDistinct, Nothing)
Notice that the 2 groups are both used, to prevent mixing products
from different company.
Thanks Shiven:) If Answer is Helpful, Please Vote -
How can I see a running balance of my itunes spending?
Is there any way I can see my running balance of what I have spent on my account? For example if I had £10 in my account and I bought one item at 99p it would show running balance history of £9.01.
iTunes will always show the balance you have remaining when you're on the iTunes Store page in iTunes and are logged into your iTunes Store account.
You can see the purchases you've made if you log into your account and click the Purchase History button.
Regards. -
TableView - How to update a running balance column after any other column in the view is re-sorted
To keep this simple and to illustrate a problem that I am trying to solve let's say we have
a domain class that contains an income per day.
This class has two persistent properties - populated from a database table - date and income.
And there is one transient property - running balance - that shows the accumulated income
starting from the first record. This property is not persisted and it is used only to show
the running/accumulated income in a table view.
This domain object is shown in a table view with three columns:
- date
- income
- running balance
The first two columns - date and income - are sortable. When the user clicks on the column
heading these can will be sorted in ascending or descending order. The running balance
column needs to reflect this change and be correctly updated.
So the question is : how would you implement the running balance update after the data in
the table has been updated by the user?
Take 1)
=============
The obvious approach is to use "setOnSort" method to consume the SortEvent event and re-sort the
data but the sort-event does not contain any useful information that would tell from which column
the sort event originated.
Take 2)
=============
Found a possible solution:
- TableView.getSortOrder() returns a list that defines the order in which TableColumn instances are sorted after the user clicked one or more column headings.
- TableColumn.getSortType() returns the sort type - ascending/descending.
- This info can be used in the TableView.setOnSort() event handler to re-sort the data and update the balance at the same time.
Take 3)
=============
When the TableView.setOnSort() event handler is called the data is already sorted therefore the only thing that needs to be done is to update the running balance.I think I understand what you're trying to do. If I've missed it, apologies, but I think this will provide you with something you can work from anyway.
I would listen to the data instead of watching specifically for sorting. This will be much more robust if you add new functionality later (such as adding and removing rows, editing the data that's there, etc).
Specifically, for the runningBalance column, create a cellValueFactory that provides a DoubleBinding; this binding should listen for changes to the data and compute the value by running through the table's items up to the point of the item for which it's displaying the value. (Hope you can untangle that sentence.)
Example. The important part is the cellValueFactory for the cumulativeAmountCol. I guess I should mention that you shouldn't try this exact approach with very large tables as the performance might be pretty bad (computations of the order of n x m on changing data, where n is the number of rows in the table and m is the number of visible rows in the table).
import java.text.DateFormat;
import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.Random;
import javafx.application.Application;
import javafx.beans.Observable;
import javafx.beans.binding.DoubleBinding;
import javafx.beans.property.DoubleProperty;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.SimpleDoubleProperty;
import javafx.beans.property.SimpleObjectProperty;
import javafx.beans.value.ObservableValue;
import javafx.collections.FXCollections;
import javafx.scene.Scene;
import javafx.scene.control.TableCell;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableColumn.CellDataFeatures;
import javafx.scene.control.TableView;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.layout.BorderPane;
import javafx.stage.Stage;
import javafx.util.Callback;
public class CumulativeTableColumnExample extends Application {
private final static int NUM_ITEMS = 20 ;
@Override
public void start(Stage primaryStage) {
final TableView<LineItem> table = new TableView<>();
// using the extractor here makes sure the table item list fires a list changed event if any amounts change
// this enables the cumulative amount column to keep up to date when the amount in a different row changes.
table.setItems(FXCollections.observableList(createRandomData(), new Callback<LineItem, Observable[]>() {
@Override
public Observable[] call(LineItem item) {
return new Observable[] {item.amountProperty()};
final TableColumn<LineItem, Date> dateCol = new TableColumn<>("Date");
final TableColumn<LineItem, Number> amountCol = new TableColumn<>("Amount");
final TableColumn<LineItem, Number> cumulativeAmountCol = new TableColumn<>("Cumulative Amount");
table.getColumns().addAll(Arrays.asList(dateCol, amountCol, cumulativeAmountCol));
dateCol.setCellValueFactory(new PropertyValueFactory<LineItem, Date>("date"));
amountCol.setCellValueFactory(new PropertyValueFactory<LineItem, Number>("amount"));
cumulativeAmountCol.setCellValueFactory(new PropertyValueFactory<LineItem, Number>("amount"));
cumulativeAmountCol.setSortable(false); // otherwise bad things might happen
final DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.SHORT);
dateCol.setCellFactory(new Callback<TableColumn<LineItem, Date>, TableCell<LineItem, Date>>() {
@Override
public TableCell<LineItem, Date> call(TableColumn<LineItem, Date> col) {
return new TableCell<LineItem, Date>() {
@Override
public void updateItem(Date date, boolean empty) {
super.updateItem(date, empty);
if (empty) {
setText(null);
} else {
setText(dateFormat.format(date));
cumulativeAmountCol.setCellValueFactory(new Callback<CellDataFeatures<LineItem, Number>, ObservableValue<Number>> () {
@Override
public ObservableValue<Number> call(CellDataFeatures<LineItem, Number> cellData) {
final LineItem currentItem = cellData.getValue() ;
DoubleBinding value = new DoubleBinding() {
super.bind(table.getItems());
@Override
protected double computeValue() {
double total = 0 ;
LineItem item = null ;
for (Iterator<LineItem> iterator = table.getItems().iterator(); iterator.hasNext() && item != currentItem; ) {
item = iterator.next() ;
total = total + item.getAmount() ;
return total ;
return value;
final NumberFormat currencyFormat = NumberFormat.getCurrencyInstance();
// generics hell.. can't wait for lambdas...
final Callback<TableColumn<LineItem, Number>, TableCell<LineItem, Number>> currencyCellFactory = new Callback<TableColumn<LineItem, Number>, TableCell<LineItem, Number>>() {
@Override
public TableCell<LineItem, Number> call(TableColumn<LineItem, Number> column) {
return new TableCell<LineItem, Number>() {
@Override
public void updateItem(Number amount, boolean empty) {
if (empty) {
setText(null) ;
} else {
setText(currencyFormat.format(amount));
amountCol.setCellFactory(currencyCellFactory);
cumulativeAmountCol.setCellFactory(currencyCellFactory);
BorderPane root = new BorderPane();
root.setCenter(table);
primaryStage.setScene(new Scene(root, 600, 400));
primaryStage.show();
public List<LineItem> createRandomData() {
Random rng = new Random();
List<LineItem> items = new ArrayList<>();
for (int i=0; i<NUM_ITEMS; i++) {
Calendar cal = Calendar.getInstance();
cal.add(Calendar.DAY_OF_YEAR, rng.nextInt(365)-365);
double amount = (rng.nextInt(90000)+10000)/100.0 ;
items.add(new LineItem(cal.getTime(), amount));
return items ;
public static void main(String[] args) {
launch(args);
public static class LineItem {
private final ObjectProperty<Date> date ;
private final DoubleProperty amount ;
public LineItem(Date date, double amount) {
this.date = new SimpleObjectProperty<>(this, "date", date);
this.amount = new SimpleDoubleProperty(this, "amount", amount);
public final ObjectProperty<Date> dateProperty() {
return date;
public final Date getDate() {
return date.get();
public final void setDate(Date date) {
this.date.set(date);
public final DoubleProperty amountProperty() {
return amount ;
public final double getAmount() {
return amount.get();
public final void setAmount(double amount) {
this.amount.set(amount); -
I want to allocate balance qty in sql.....
Please help me…
I want to allocate balance qty in sql.....
I have data like below table and expected answer in column EDIT_UP_TO_EXEPECTED_ANS.
I want to edit data with validation of next process executed qty.
for example in row 3rd and 4th PROCESS_EXECUTE_QTY is ORDER_VRNO wise is 100 i.e.
100+0=100 and i want to allocated this qty in 1st and 2nd row i.e. 75,25 i.e. 75+25=100
because first process CUTTING of jobcard_no J113Y-1004 is 75 and next process done is 100 order_vrno wise
so i want to allocated 100 in 75,100 i.e. 75,25 total should be next process execute qty i.e. 100
SLNO
JOBCARD_NO
ORDER_VRNO
PROCESS_CODE
PROCESS_EXECUTE_QTY
EDIT_UP_TO_EXPECTED_ANS
1
J113Y-1004
P113Y-56
CUTTING
75
75
2
J113Y-1005
P113Y-56
CUTTING
100
25
1
J113Y-1004
P113Y-56
DRILLING
100
85
2
J113Y-1005
P113Y-56
DRILLING
0
0
1
J113Y-1004
P113Y-56
PUNCHING
15
15
2
J113Y-1005
P113Y-56
PUNCHING
0
0
1
J113Y-1004
P113Y-56
FORMING
0
0
2
J113Y-1005
P113Y-56
FORMING
0
0
Table script ....
with t as
(select 1 SLNO,'J113Y-1004' jobcard_no,'P113Y-56' ORDER_VRNO,'CUTTING' PROCESS_CODE,75 PROCESS_EXECUTE_QTY, 75 EDIT_UP_TO_EXEPECTED_ANS FROM DUAL
UNION ALL
select 2 SLNO,'J113Y-1005' jobcard_no,'P113Y-56' ORDER_VRNO,'CUTTING' PROCESS_CODE,100 PROCESS_EXECUTE_QTY, 25 EDIT_UP_TO_EXEPECTED_ANS FROM DUAL
UNION ALL
select 1 SLNO,'J113Y-1004' jobcard_no,'P113Y-56' ORDER_VRNO,'DRILLING' PROCESS_CODE,100 PROCESS_EXECUTE_QTY,85 EDIT_UP_TO_EXEPECTED_ANS FROM DUAL
UNION ALL
select 2 SLNO,'J113Y-1005' jobcard_no,'P113Y-56' ORDER_VRNO,'DRILLING' PROCESS_CODE,0 PROCESS_EXECUTE_QTY,0 EDIT_UP_TO_EXEPECTED_ANS FROM DUAL
UNION ALL
select 1 SLNO,'J113Y-1004' jobcard_no,'P113Y-56' ORDER_VRNO,'PUNCHING' PROCESS_CODE,15 PROCESS_EXECUTE_QTY, 15 EDIT_UP_TO_EXEPECTED_ANS FROM DUAL
UNION ALL
select 2 SLNO,'J113Y-1005' jobcard_no,'P113Y-56' ORDER_VRNO,'PUNCHING' PROCESS_CODE,0 PROCESS_EXECUTE_QTY, 0 EDIT_UP_TO_EXEPECTED_ANS FROM DUAL
UNION ALL
select 1 SLNO,'J113Y-1004' jobcard_no,'P113Y-56' ORDER_VRNO,'FORMING' PROCESS_CODE,0 PROCESS_EXECUTE_QTY, 0 EDIT_UP_TO_EXEPECTED_ANS FROM DUAL
UNION ALL
select 2 SLNO,'J113Y-1005' jobcard_no,'P113Y-56' ORDER_VRNO,'FORMING' PROCESS_CODE,0 PROCESS_EXECUTE_QTY, 0 EDIT_UP_TO_EXEPECTED_ANS FROM DUAL)
SELECT SLNO,JOBCARD_NO,ORDER_VRNO,PROCESS_CODE,PROCESS_EXECUTE_QTY,EDIT_UP_TO_EXEPECTED_ANS FROM T
i am using
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
version.
thanks.Just a guess ( with some data changed and an order column added)
with t as
(select 1 SLNO,'J113Y-1004' jobcard_no,'P113Y-56' ORDER_VRNO,'CUTTING' PROCESS_CODE,1 ord,75 PROCESS_EXECUTE_QTY,0 EDIT_UP_TO_EXEPECTED_ANS FROM DUAL UNION ALL
select 2,'J113Y-1005','P113Y-56','CUTTING',1,100,0 FROM DUAL UNION ALL
select 1,'J113Y-1004','P113Y-56','DRILLING',2,85,0 FROM DUAL UNION ALL
select 2,'J113Y-1005','P113Y-56','DRILLING',2,0,0 FROM DUAL UNION ALL
select 1,'J113Y-1004','P113Y-56','PUNCHING',3,15,0 FROM DUAL UNION ALL
select 2,'J113Y-1005','P113Y-56','PUNCHING',3,0,0 FROM DUAL UNION ALL
select 1,'J113Y-1004','P113Y-56','FORMING',4,0,0 FROM DUAL UNION ALL
select 2,'J113Y-1005','P113Y-56','FORMING',4,0,0 FROM DUAL
SLNO
JOBCARD_NO
ORDER_VRNO
PROCESS_CODE
ORD
PROCESS_EXECUTE_QTY
EDIT_UP_TO_EXEPECTED_ANS
1
J113Y-1004
P113Y-56
CUTTING
1
75
0
2
J113Y-1005
P113Y-56
CUTTING
1
100
0
1
J113Y-1004
P113Y-56
DRILLING
2
85
0
2
J113Y-1005
P113Y-56
DRILLING
2
0
0
1
J113Y-1004
P113Y-56
PUNCHING
3
15
0
2
J113Y-1005
P113Y-56
PUNCHING
3
0
0
1
J113Y-1004
P113Y-56
FORMING
4
0
0
2
J113Y-1005
P113Y-56
FORMING
4
0
0
SELECT SLNO,JOBCARD_NO,ORDER_VRNO,PROCESS_CODE,ord,PROCESS_EXECUTE_QTY,
case when slno = 2
then PROCESS_EXECUTE_QTY - lag(PROCESS_EXECUTE_QTY ) over (order by ord,slno)
else PROCESS_EXECUTE_QTY
end EDIT_UP_TO_EXEPECTED_ANS
from (SELECT SLNO,JOBCARD_NO,ORDER_VRNO,PROCESS_CODE,ord,
case when slno = 2
then first_value(process_execute_qty) over (order by ord,slno desc)
else PROCESS_EXECUTE_QTY
end PROCESS_EXECUTE_QTY,
EDIT_UP_TO_EXEPECTED_ANS
FROM T
order by ord,slno
SLNO
JOBCARD_NO
ORDER_VRNO
PROCESS_CODE
ORD
PROCESS_EXECUTE_QTY
EDIT_UP_TO_EXEPECTED_ANS
1
J113Y-1004
P113Y-56
CUTTING
1
75
75
2
J113Y-1005
P113Y-56
CUTTING
1
100
25
1
J113Y-1004
P113Y-56
DRILLING
2
85
85
2
J113Y-1005
P113Y-56
DRILLING
2
100
15
1
J113Y-1004
P113Y-56
PUNCHING
3
15
15
2
J113Y-1005
P113Y-56
PUNCHING
3
100
85
1
J113Y-1004
P113Y-56
FORMING
4
0
0
2
J113Y-1005
P113Y-56
FORMING
4
100
100
Regards
Etbin -
BPC10NW: Error while running Balance Carry Forward
Hi,
I am trying to run 'Balance Carry Forward' (COPYOPENING) to copy opening balances from 2010.DEC to 2011.JAN.
The 'Opening Balances' package fails with "RUN_LOGIC:Cannot find document/directory" error.
The Copyopening.lgf is available and is been validated successfully.
We have refered to the below link but still the opening balances is failing with the same error.
http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/70657540-106d-2e10-8393-d702056767a4?QuickLink=index&overridelayout=true
Any suggestions?
thanks in advance,
M.SHi,
I have found similar issues with business rules in v10.
Can you just try to include this in Default logic and see if you can get it to run from a sent record. I know that this is not necessarily the nicest approach as you would normally like to run the package from DM, but I could not get certain things to run from DM.
If (like me) you can get it to run via Default, you could then trigger this by sending a dummy record to a dummy account.
I know it's not ideal but until this is fixed (I think it may be a bug) then this could be a solution.
Let me know if this helps at all.
Tom. -
How to run multiple scripts in sql*plus?
I would like to run 2 scripts in sql*plus, how do I do this? I tried the following, but it won't run.
create table student_new
AS
select *
from student
insert into student_new
(last_name, first_name
values
(Crop, Jenny)
The above are the two scripts I want to run, what am I doing wrong.
ThanksDo you have a solution to run multiple scripts continuosly, one after the other as one script.
Say I have file1.sql file2.sql, file3.sql.
I want to create a script run.sql, where this will run file1.sql,file2.sql,file3.sql one after other without any one running one after the other like follows:
run.sql should have
begin
@file1.sql
@file2.sql
@file3.sql
dbms_output.put_line(select sysdate from dual);
end;
If I run run.sql all the three scripts should be executed successfully and then display the current time . All these files have update statements(50,000 updates each file).
Very urgetn. Can some one hlpe, please.
Thanks in advance. -
Running a anonymous PL/SQL block
Hi,
I have created an anonymous PL/SQL block and saved it in a file. And I am now trying to run it from the sql prompt using @.
But this doesn't seem to be working. I get a wierd number as output and then it hangs.
This is not the case if I copy paste the anonymous block. In this case I get the correct output.
Please assist as to whether it is possible to run it using @ as it is important for me to do so..Hi,
You forgot the slash after the anonymous block:
USER is "YJAM"
TEST>-- Create anonymous Block
TEST>BEGIN
2 NULL;
3 END;
4 /
PL/SQL procedure successfully completed.
TEST>-- save as script
TEST>save ab.sql
Created file ab.sql
TEST>get ab
1 BEGIN
2 NULL;
3* END;
TEST>@ab
PL/SQL procedure successfully completed.
TEST>ed ab Here, I delete line 4. hence the Block won't run.
TEST>@ab
4
5
6
7
8 . a dot to exit input mode. a slash would run the block
TEST>Regards,
Yoann. -
How do I "fill down" a formula in a spreadsheet to get a running balance of payments and deposits
How do I FILL DOWN a formula in a spreadsheet to get a running balance of payments and deposits?
using what spreadsheet program?
-
Stopped server while running full synchronization of SQL MA
Hi Everyone,
I am currently facing an issue in the Sync server where the Full Sync is showing "Stopped server" while running Full Synchronization of SQL MA and this is not happending regularly as it is showing the error message 3 times if it runs 10 times in
a week and rest 7 times its running fine.
What could be the reason why this is occuring?
Your response will be highly appreciated
Thanks,
AmanHi Nosh,
My first profiler is FI & FS then i am running FS in which i am facing this issue of stopped server and second thing is that the above thing is running absolutly fine with ILM but in FIM its shwoing this error and this error is not permanent as
it is failing two times then third time it is running perfectly.
Please suggest
Thanks,
Aman -
Filtering transactions resulting in incorrect running balance.
Hi ,I am back with another simple problem.
I have a list of transactions which are with dates out of order.
The last column is a running balance(starts off with a balance of 2, ending with a balance of 41)
2
5 Apr 2008 Charles Food 8 10
5 Apr 2008 Harry Food 2 12
1 Apr 2008 Barry petrol 2 14
1 Apr 2008 Jim Petrol 6 20
1 Apr 2008 Steven Petrol 9 29
1 Jan 2008 Jack Food 12 41
However when I run a filter on ascending dates, I get the following
Which gives an incorrect balance.
What am I doing Wrong?
1 Jan 2008 Jack food 12 41
1 Apr 2008 Barry petrol 2 14
1 Apr 2008 Jim Petrol 6 20
1 Apr 2008 Steven Petrol 9 29
5 Apr 2008 Charles Food 8 10
5 Apr 2008 Harry Food 2 12
2
By the way I tried to insert a copy of the spreadsheet to show exactly what I am doing, without success.
How do I insert pictures on the discussion group?
Thanks-chatchpw1840 wrote:
Yvan's revised formula works beautifully when the E is replaced with another INDIRECT/ADDRESS segment:
=INDIRECT(ADDRESS(ROW()-1,COLUMN()))+INDIRECT(ADDRESS(ROW(),COLUMN()-1))
my late formula
=INDIRECT(ADDRESS(ROW()-1.COLUMN()))+E
works flawlessly
No need for indirect addressing for the value grabbed from the current row.
It's a side effect of the use of the single column letter in the cell reference.
One issue that has not been dealt with is the starting balance "2" which sorts to the bottom of the list. The final balance is correct, of course, but the intermediate cumulations do not reflect that value as one might expect. Placing an early, out of range date in the "2" row along with some statement like "Prior Balance" in column B would solve this problem.
Of course, I didn't insert the row containing the 2 in the range to sort;-)
Yvan KOENIG (from FRANCE mardi 17 juin 2008 21:41:31)
Maybe you are looking for
-
How do i delete programs from my MacBook Pro
how do i delete programs from my MacBook Pro?
-
Terrible Sony Customer Service
Hi, I am posting this message here as a first step to create awareness regarding Sony's awful customer service. I stay in Toronto, Canada. My laptop's screen had issues with it and so I wanted to send it in for repair. I called Sony and they told me
-
Hi, i have just serviced a HP 2600N as the colours were fading on prints. I took the printer apart and cleaned the mirrors and plastic lenses and is something i have done on a few of these printers now. One printer refuses to pick up paper however, a
-
Implementing a graph scrolling using JScrollPane component
I would like to ask a question apropos using of JScrollPane component. A part of the default behaviour of this component is adjusting the component's state when the size of the client changes. But, I need to achieve an opposite effect - I need to adj
-
Export Data Using Escape Character
Hi All I have got a requirement where i need to export data from oracle with escape character. eg. I am using a delimiter 237(í) and if the same character is present in data it should be escaped by escape character eg. /. Once this file will get crea