Running total and calc between two column (subtraction)
Hi Experts!,
I have a simple requirement but getting me frustrated :( I need to calculate stock on a series of transaction
this is my order table:
OrderNo | Item | Delivery | OrderQty
A-101 | G001 | 20110721 | 200
A-104 | G001 | 20110722 | 300
A-102 | GA02 | 20110721 | 210
and my stock table :
Item | stockQty
G001 | 300
GA02 | 0
What i want to accomplish is something like this:
OrderNo | Item | Delivery | OrderQty | StockOut
A-101 | G001 |20110721 | 200 | 200
A-104 | G001 |20110722 | 300 | 100
A-102 | GA02 |20110721 | 210 | 0
i believe there is must be a way to accomplish this, without using to create extra dummy table to store
qty of Stock out (stock-orderqty),
waiting for respons,
Thanks!
Try this
with order1
as
select 'A-101' orderno, 'G001' item, 20110721 delivery, 200 orderqty from dual union all
select 'A-104', 'G001', 20110722, 300 from dual union all
select 'A-105', 'G001', 20110723, 250 from dual union all
select 'A-102', 'GA02', 20110721, 210 from dual union all
select 'A-103', 'GA02', 20110721, 300 from dual
), stock
as
select 'G001' item, 600 stockqty from dual union all
select 'GA02', 500 from dual
select orderno, item, delivery, orderqty, case when qty <= stockqty then orderqty else stockqty - qty1 end stockout
from (
select orderno, item, delivery, orderqty, qty, nvl(lag(qty) over(partition by item order by orderno), 0) qty1, stockqty
from (
select orderno, o.item, delivery, orderqty, sum(orderqty) over(partition by o.item order by orderno) qty, stockqty
from order1 o
join stock s
on o.item = s.item
)Note: Tables defined in the WITH caluse are sample table to show you how the SQL works. You can just use the SELECT statement with your original table.
Similar Messages
-
Running Total and In Current Year Columns Source
Hi all,
What is the source for Running Total and In Current Year Columns from Absence Detail Screen.
From Which tables can I get the information on those columns.
Thanks in AdvanceHello,
I am still struck with Running Total Column
When i fetch running total using this query it works for some of the employees
SELECT SUM(ABSENCE_hours) from PER_ABSENCE_ATTENDANCES where person_id = <your person id> and absence_attendance_type_id = <your absence type id>
As there are three different cases here as Days,Hours and No Balance
I am missing the logic again here when it comes for no balance and days
Thanks -
How to get the difference between two columns in a column group
Hi All,
My first time here and really new to programming. I would like to get the difference between 2 columns that are inside
a column group.
Here is my sample table below: The Column Group is PeriodNumber and can only choose 2. like 1 and 2.. I would like to have a third row which will simply calculate the difference between the amounts in PeriodNumber 1 and 2.
PeriodNumber
Account 1 2
1) Cash 10,000 15,000
2) Receivables 12,000 11,500
3) Equipment 5,000 5,500
Total Assets 27,000 32,000Hi yabgestopa,
From your description, you want to get the difference between two columns in a column group. After testing it in my environment, we can use custom code to achieve your requirement. For more details, you can refer to the following steps:
Copy the custom code below and paste it to your report. (Right-click report>Report Properties>Code)
Dim Shared Num1 As Integer
Dim shared Num2 As Integer
Public Function GetAmount(Amount as Integer, Type as String)
If Type = "1" Then
Num1=Amount
Else
Num2=Amount
End If
Return Amount
End Function
Public Function GetDif()
Return Num1-Num2
End function
Right-click the second column to insert a third column with Outside Group-Right.
Then use the expressions below in the matrix.
=Code.GetAmount(Fields!Amount.Value,Fields!PeriodNumber.Value)
=code.GetAmount(Sum(Fields!Amount.Value),Fields!PeriodNumber.Value)
=Code.GetDif()
The report looks like below.
If you have any questions, please feel free to ask.
Thanks,
Katherine Xiong
Katherine Xiong
TechNet Community Support -
Error while running code template mapping between two oracle tables
Hello All
Iam getting the following error while running code template mapping between two oracle tables. Using OWB 11gR2 and oracle 11gR2 DB.
java.sql.SQLException: ORA-20001: The active workspace is not valid as a target for this mapping
c: at "OWBSYS.WB_RT_MAPAUDIT_UTIL", line 1065
ORA-06512: at "OWBSYS.WB_RT_MAPAUDIT_UTIL", line 1087
ORA-06512: at "SOURCE.FILENET_EX_UNIT_3", line 555
ORA-06512: at line 4
Job 51 error: java.sql.SQLException: ORA-20001: The active workspace is not valid as a target for this mapping
ORA-06512: at "OWBSYS.WB_RT_MAPAUDIT_UTIL", line 1065
ORA-06512: at "OWBSYS.WB_RT_MAPAUDIT_UTIL", line 1087
ORA-06512: at "SOURCE.FILENET_EX_UNIT_3", line 555
ORA-06512: at line 4
Quick help is highly appreciated.Dera Dallan
its only a target user for the workspace where you are deploying the mapping from.
I have two repositories for two different projects. each repositary has its own workspace.
ex:-
Project 1
Work space bpms_rep_owner
Repositary owner bpms_rep_owner
Repositary user bpms_rep_user
Project 2
Work space dem_rep_owner
Repositary owner dem_rep_owner
Repositary user dem_rep_user
Reg
S.Gyazuddin -
Find the difference between two columns in an ssrs matrix ? MSCRM
Hi All,
I am working in reporting part of our project (On-line MSCRM 2013) & in reporting services.
I am trying to create report using fetch xml based. Below is the snap what we required the result.
Kindly help me, how to get the difference in both column. (Its a matrix table where year is grouped).
We need difference between both year Like (Plan Revenue of 2013 & Plan Revenue of 2014 difference in Plan Revenue Diff section) and same for Actual
Revenue.
https://social.microsoft.com/Forums/en-US/054d5ca4-0d38-4dc6-84a8-88866cc228fe/find-the-difference-between-two-columns-in-an-ssrs-matrix-mscrm?forum=crmdevelopment
Thanks,
Mohammad ShariqueHi Bro,
I used parametrized option for year and done the report,Currently we are getting values in Difference column now i want to show
that value in percentage. How can we show the percentage based on that value. Means i want to show the Difference in Percentage.
Kindly help me i tried but getting some issue. Below i am mentioning the code and snap with result.
Below expression using to showing Plan Revenue in Percentage for year.
=
Sum(IIF(Fields!new_year.Value =Parameters!StartYear.Value,cdec(Fields!new_planrevenueValue.Value/1000), cdec(0)))
- Sum(IIF(Fields!new_year.Value =Parameters!EndYear.Value,cdec(Fields!new_planrevenueValue.Value/1000), cdec(0)))
/IIF(Sum(IIF(Fields!new_year.Value = Parameters!StartYear.Value,cdec(Fields!new_planrevenueValue.Value/1000), cdec(0)))>0,
(Sum(IIF(Fields!new_year.Value = Parameters!StartYear.Value,cdec(Fields!new_planrevenueValue.Value/1000), cdec(0))))
,1)
)*100))
Result issue is as below in snap with highlighted in red colour.
Kindly help me on this issue also :) -
How to find differences between two columns
Hello I need the formula to spot differences between two columns and to write on a third one if the same name appear on the two columns.
For example:
rome berlin true
berlin moscow false
chicago toronto true
toronto chicago true
florence
Thanks
LorenzoYou should be able to use COUNTIF where the range is th first column and the condition is the word in the second column. If the result is greater than zero then the word is in both columns.
-
Can i share music and photos between two users on the same machine?
How can I share my music and photos between two users on the same machine?
Thank you Joe - I tried this but it's only showing a teensy amount of music - the stuff on the second users account as opposed to the giagntic library on the 'main' account. I actually went to a Genius Bar and they said that apple doesn't really want you to share music between accounts - parents don't want to hear their kids music etc. Which seemed strange, but it might be the case sadly Thanks anyway!
-
HT204053 how do I share calendars and music between two ID's?
How do I share calendars and music between two Apple ID's? We have a Mac Pro and two Iphones. Currently we utilize one ID between the Iphones in order to sync the calendars and music.
You can privately share a calendar between devices using different iCloud IDs as explained here: http://help.apple.com/icloud/#mm6b1a8694. Even if your devices use different IDs for iCloud you can continue to share the same ID for iTunes to share your music and other purchased media. The ID you use on a device for iCloud does not need to be the same as the ID used for iCloud.
-
Drag and Drop between two windows
I would like to implement Drag and Drop between two windows for example in Windows I can take URL Address form browser and drag it and drop it in to any control that excepts String like TextField.
I would like to have the same behavior with my Java Text Controls.
What can I do to achieve this?There is no configuration for it. It should work.
Can you try it in a different user account. If it works in a different account, then it is likely something in your current user account that is messed up. If it doesn't work in another user account, then it is likely something with Mail, itself.
You could try downloading and installing the 10.6.7 combo update. That may repair what is wrong. -
Drag and Drop between two JTables
I tried to implement drag and drop between two JTables using data transfer, but i did not get it to work, that dnd works in both directions. i have my own transferhandler, but if is use setTransferHandler(handler), i'm no longer able to start a drag from that table. i also tried to use a mouse listener to call exportAsDrag, but i only works in one direction. any ideas or examples?
That is a rather large request, and indicates that you have likely not spent much time researching the subject before posting. Read up on Swing drag & drop here (http://java.sun.com/docs/books/tutorial/dnd/), then ask specific questions about something you don't understand, problems with your implementation, etc.
Mike -
Drag and drop between two different browser
Hi All,
Is drag and drop in flex possible behind boundaries of
browser context?.
Currently i have a vdividebox which contains two datagrid
with drag and drop functionality.
Now I want to display this datagrid in two different browsers
and provide the drag and drop functionality between them.
Is their any way to achieve this?
Thanks.Hey
due to Security restrictions (Sandbox) I don't believe that
you can Drag and Drop between two Browsers with Flex, maybe this
can be done with AIR.
Cheers
Dietmar -
Drag and Drop between two list boxes
Hi all
I am working over Drag and Drop .. i have to implement Drag and Drop between two list boxes .. both list box exist in same page ..each list box have number of rows.. please give me some idea ... as i am new for JSP and Servlet...
Thanks in advance
Regards
VaibhavHi all
I am working over Drag and Drop .. i have to
implement Drag and Drop between two list boxes ..
both list box exist in same page ..each list box have
number of rows.. please give me some idea ... as i am
new for JSP and Servlet...
Something close to what you are looking for is Select Mover in Coldtags suite:
http://www.servletsuite.com/jsp.htm -
Drag and Drop between two java applications
Hi,
I am trying to implement drag and drop between two instances of our java application. When i drop the content on the target, the data flavors are transmitted properly, but i get the exception :
java.awt.dnd.InvalidDnDOperationException: No drop current
at sun.awt.dnd.SunDropTargetContextPeer.getTransferData(SunDropTargetContextPeer.java:201)
at sun.awt.datatransfer.TransferableProxy.getTransferData(TransferableProxy.java:45)
at java.awt.dnd.DropTargetContext$TransferableProxy.getTransferData(DropTargetContext.java:359)
at com.ditechcom.consulbeans.TDNDTree.drop(TDNDTree.java:163)
at java.awt.dnd.DropTarget.drop(DropTarget.java:404)
at sun.awt.dnd.SunDropTargetContextPeer.processDropMessage(SunDropTargetContextPeer.java:547)
How can i fix this ?
Thanks a lot,
KarthikPlay with this;-import java.awt.*;
import java.awt.datatransfer.*;
import java.awt.dnd.*;
import java.awt.event.*;
import javax.swing.*;
import java.io.*;
// Credit to bbritna who I stole it from in the 'New To ..' Forum
public class DragComps implements DragGestureListener, DragSourceListener,
DropTargetListener, Transferable{
static final DataFlavor[] supportedFlavors = { null };
static{
try {
supportedFlavors[0] = new DataFlavor(DataFlavor.javaJVMLocalObjectMimeType);
catch (Exception ex) { ex.printStackTrace(); }
Object object;
// Transferable methods.
public Object getTransferData(DataFlavor flavor) {
if (flavor.isMimeTypeEqual(DataFlavor.javaJVMLocalObjectMimeType))
return object;
else return null;
public DataFlavor[] getTransferDataFlavors() {
return supportedFlavors;
public boolean isDataFlavorSupported(DataFlavor flavor) {
return flavor.isMimeTypeEqual(DataFlavor.javaJVMLocalObjectMimeType);
// DragGestureListener method.
public void dragGestureRecognized(DragGestureEvent ev) {
ev.startDrag(null, this, this);
// DragSourceListener methods.
public void dragDropEnd(DragSourceDropEvent ev) { }
public void dragEnter(DragSourceDragEvent ev) { }
public void dragExit(DragSourceEvent ev) { }
public void dragOver(DragSourceDragEvent ev) {
object = ev.getSource(); }
public void dropActionChanged(DragSourceDragEvent ev) { }
// DropTargetListener methods.
public void dragEnter(DropTargetDragEvent ev) { }
public void dragExit(DropTargetEvent ev) { }
public void dragOver(DropTargetDragEvent ev) {
dropTargetDrag(ev); }
public void dropActionChanged(DropTargetDragEvent ev) {
dropTargetDrag(ev); }
void dropTargetDrag(DropTargetDragEvent ev) {
ev.acceptDrag(ev.getDropAction()); }
public void drop(DropTargetDropEvent ev) {
ev.acceptDrop(ev.getDropAction());
try {
Object target = ev.getSource();
Object source = ev.getTransferable().getTransferData(supportedFlavors[0]);
Component component = ((DragSourceContext) source).getComponent();
Container oldContainer = component.getParent();
Container container = (Container) ((DropTarget) target).getComponent();
container.add(component);
oldContainer.validate();
oldContainer.repaint();
container.validate();
container.repaint();
catch (Exception ex) { ex.printStackTrace(); }
ev.dropComplete(true);
public static void main(String[] arg) {
JButton button = new JButton("Drag this button");
JLabel label = new JLabel("Drag this label");
JCheckBox checkbox = new JCheckBox("Drag this check box");
JFrame source = new JFrame("Source Frame");
Container source_content = source.getContentPane();
source.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
source_content.setLayout(new FlowLayout());
source_content.add(button);
source_content.add(label);
JFrame target = new JFrame("Target Frame");
Container target_content = target.getContentPane();
target.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
target_content.setLayout(new FlowLayout());
target_content.add(checkbox);
DragComps dndListener = new DragComps();
DragSource dragSource = new DragSource();
DropTarget dropTarget1 = new DropTarget(source_content,
DnDConstants.ACTION_MOVE, dndListener);
DropTarget dropTarget2 = new DropTarget(target_content,
DnDConstants.ACTION_MOVE, dndListener);
DragGestureRecognizer dragRecognizer1 =
dragSource.createDefaultDragGestureRecognizer(button,
DnDConstants.ACTION_MOVE, dndListener);
DragGestureRecognizer dragRecognizer2 =
dragSource.createDefaultDragGestureRecognizer(label,
DnDConstants.ACTION_MOVE, dndListener);
DragGestureRecognizer dragRecognizer3 =
dragSource.createDefaultDragGestureRecognizer(checkbox,
DnDConstants.ACTION_MOVE, dndListener);
source.setBounds(0, 200, 200, 200);
target.setBounds(220, 200, 200, 200);
source.show();
target.show();
}[/code -
How to Summarized Running Total and Formula ????
Post Author: ryan_r
CA Forum: Crystal Reports
Hi my name is Ryan, I want to ask something. I have build a report
that contains Running totals and Formula. What I want to do is I want
to use subtotal and Summary field for the running total and Formula,
but I can find the field when I click the dropdownlist in the Subtotal
dialog box or summary field for the running total and the formula. Is
there any way that I can use subtotal or summary field for Running
Totals and formula, I do need some help guys, Thanks. FYI: I use Visual Studio.NET 2003; ASP.NET(C#).regardsPost Author: ryan_r
CA Forum: Crystal Reports
Hi kcheeb, thanks for your advice but it doesn't work sorry. By the way maybe I can explain you more of twisted situation.I have updated my report,
so im not using runningtotals any more, I'm using summary field and
formula which are;-the summary field is "Sum of SuspenseVoucher.Realisation" located in Group Footer #3: SuspenseMstr.ProgramID-The formula is "@Balance_Formula" which contain:{SuspenseMstr.Budget}
- Sum ({SuspenseVoucher.PenggunaanBudget}, {SuspenseMstr.ProgramID})
also located in the same location as summary field above.FYI: I have three group records which are:-Group #1 : SuspenseMstr.APDate (Appearing in months e.g January 2007)-Group
#2 : programCategoryMstr.programCategoryID (doesn't have any objects I
just put some dashed line, the group is only for proper sorting)-Group #3: SuspenseMstr.ProgramIDwhat I want to do is:-in the Group Footer #3, I already put "Sum of SuspenseVoucher.Realisation" and "@Balance_formula"-in
the Group Footer #2, I want to put Summary of Budget but there's a
problem in here too, in the budget field there are some data are
conditionally suppressed. I already tried to put some summary field but
the summary operation wasn't like what I wanted. What I wanted was the
sum only evaluate the data that appeared in the report not the
suppressed, but in the summary the suppressed data keep evaluated. And
in this location I also want to put Summary of "Sum of
SuspenseVoucher.Realisation" and the Sum of the @Balance_formula.-
in the Group Footer #1, I want to add some Summary of "Sum of Budget"
(which I already explained that this operation has a problem) and I
also want to put the Sum of "Summary of Sum of
SuspenseVoucher.Realisation" and the Sum of "Sum of @Balance_formula"-And in the Report Footer I want to add some Grand Total from all of the evaluation above.So
there are my problems, quite much I would say. I hope this explanation
helping all of you guys to solve my problem, thanks for spending your
valuable time for me. This matter is really important for me 'cause I
want to learn something new from all of you experts as I'm still a
"toddler" in this situation and also because I work in this field, so a
BIG thank you for all of you guys out there. Best Regards. -
How to count the number of Fridays and Saturdays between two dates
Hi every one ... If we want to count the number of Fridays and Saturdays between two dates, how would we do that ? !
Dates are ( 11-Feb-2010) to (19-May-2010)
how to do it in SQL
Edited by: khalidoracleit on Jul 28, 2010 5:51 AMsome nice coding here, I'm still amazed with what some people can do with "connect by". But I agree with some statements here that this can take "time", and to be honest, it's funny to see it working, but if you do not have a computer, just a calendar and some paper, would you go for "counting" so there must be a better solution?
The best working math in here is done by Aketi Jyuuzou, who writes so good English that I wonder why he still insists that he doesn't ;-)
Anyhow I "translated" that code to English, and I really like that math. Math is math and data is data.
ALTER SESSION SET NLS_DATE_LANGUAGE='ENGLISH';
WITH my_dates AS (
SELECT to_date('20100211','yyyymmdd') start_date,to_date('20100519','yyyymmdd') end_date FROM DUAL
UNION ALL
SELECT to_date('20100211','yyyymmdd') start_date,to_date('20100214','yyyymmdd') end_date FROM DUAL
UNION ALL
SELECT to_date('20100211','yyyymmdd') start_date,to_date('20100213','yyyymmdd') end_date FROM DUAL
UNION ALL
SELECT to_date('20100211','yyyymmdd') start_date,to_date('20100212','yyyymmdd') end_date FROM DUAL
SELECT to_char(start_date,'DD.MM.YYYY') start_date,to_char(end_date,'DD.MM.YYYY') end_date,
to_char(start_date,'DAY') start_weekday,to_char(end_date,'DAY') end_weekday,
end_date-start_date day_difference,
(next_day(end_date,'FRIDAY')-7
-next_day(start_date -1,'FRIDAY'))/7+1
+(next_day(end_date,'SATURDAY')-7
-next_day(start_date -1,'SATURDAY'))/7+1 as count_of_fr_and_sat
FROM my_dates;
START_DATE END_DATE START_WEEKDAY END_WEEKDAY DAY_DIFFERENCE COUNT_OF_FR_AND_SAT
11.02.2010 19.05.2010 THURSDAY WEDNESDAY 97 28
11.02.2010 14.02.2010 THURSDAY SUNDAY 3 2
11.02.2010 13.02.2010 THURSDAY SATURDAY 2 2
11.02.2010 12.02.2010 THURSDAY FRIDAY 1 1 -- andy
Maybe you are looking for
-
Can't Download Photos to Adobe Photoshop Elements after iPhone Upgrade
Howdy, I have been using Adobe Photoshop Elements 4.0 with my iPhone ever since I bought my iPhone 3G when they came out and have never had any trouble. Whenever I synced my phone and there were new photos on it, Photoshop Elements would start it's p
-
Jabber for windows only allows the logged-in AD user to log into his jabber account only
Hello gang, I have this strange issue with jabber for windows 10.5. So if you log into a pc with your microsoft active directory domain account and try to log into jabber with the same user credentials, you can log-in fine. However, if you try to
-
Question: Why when downloading a purchased movie from ITunes does it take 8 to 17 hours to download? I have an HP Laptop with Windows 7 using a core processer i7. This is the second day to try to get the movie downloaded and I still cannot watch t
-
HT4993 iPhone 4s IOS 6.1.1 Calendar issue
I upgraded my iPhone 4s to iOS 6.1.1 two days, after the upgrade, my calendar is not working correctly. Any event which is not created by me could not be edited, As soon as I open the event, I get either to "decline", "MAyBe" or "Accept" option. Even
-
Multiple Screens in Mac OS 10.5.6
Hi everyone, I was wondering if it's possible to connect one screen with VGA to another screen and then connect one of those screens to a macbook pro and have them both working? Or do you realy need to buy an adaptor or firewire screen for that? I ho