Multiply coumn with +1 or -1
Multiply with -1 or +1Question:
I have two columns namely AMOUNT and IMPACT.
AMOUNT has dollar amount its of type float
IMPACT has either + or - symbol that is plus or minus symbol sadly its of type VARCHAR2.
Now i need to calculate a new column by multiplying AMOUNT with IMPACT.
So if i have
100 +
200 -
300 +
34 -
I should get
100
-200
300
-34
For every amout that has minus symbol it need to get multiplied by -1 and show a negative value in the resultant column. similarly if i have a + teh value should get multiplied by +1 and remain the same.
If i encounter something else other than - it should still be treated as 1.
I know i am not putting it in right syntax but something like this i guess
CASE
WHEN '+' THEN 1
WHEN '-' THEN -1
ELSE 0
Try something like:
SQL> -- generating your sample data:
SQL> with t as (
2 select 100 amount, '+' impact from dual union
3 select 200, '-' from dual union
4 select 300, '+' from dual union
5 select 34, '-' from dual union
6 select 3400, '¿?' from dual
7 )
8 --
9 -- actual query:
10 --
11 select amount
12 , impact
13 , to_number( case
14 when impact = '+' then amount*1
15 when impact = '-' then amount*-1
16 else amount*1
17 end
18 ) new_amount
19 from t;
AMOUNT IMP NEW_AMOUNT
34 - -34
100 + 100
200 - -200
300 + 300
3400 ¿? 3400
Similar Messages
-
How to create a matrix with constant values and multiply it with the output of adc
How to create a matrix with constant values and multiply it with the output of adc
nitinkajay wrote:
How to create a matrix with constant values and multiply it with the output of adc
Place array constant on diagram, drag a double to it, r-click "add dimension". There, a constant 2D double array, a matrix.
/Y
LabVIEW 8.2 - 2014
"Only dead fish swim downstream" - "My life for Kudos!" - "Dumb people repeat old mistakes - smart ones create new ones."
G# - Free award winning reference based OOP for LV -
Replace colors on multiply layer with predefined color
Hello,
This is my first time here and I've tried to find an answer to my question but haven't been able to. Maybe someone can help me whith this.
My process:
I scann my artwork (linedrawing)
I color my artwork with multiply mode on different layers (as i'm sure many do)
Now what I haven't been able to figure out is how to replace the color on this multiply layer with a predefined color from my colorswatch.
I've found tutorials on how you can change colour around by using hue/saturation and stuff like that but I have a predefined colorpalette. So I just want to replace a certain color blue I always work with, for a specific color green from my palette.
I've used the replace brush tool but the colors that appear are a blend of the first color and the second color I use.
So my solution so far has been to set up a new layer and color again. I'm hoping there is an easier way.
Thanks in advance for your suggestions!
Kind regards,
Lineke from AmsterdamYou could have a Color Fill layer for each color selected from your Swatches, with the blending mode set to Multiply, and the layer mask filled with black. Then, paint on the mask with white to do your coloring.
-
Multiplying Measures with different dimensionality
New to Essbase but very experienced with OLAP
My cube has 3 dimensions FCO, STAT and VALID
1st Measure DATA1 is stored at the leaf values for FCO and STAT and at the VALIDTotal (parent) for the Valid Dim
2nd Measure DATA2 is stored at the leaf values for FCO and VALID and at the StatTotal (parent) for the Stat Dim
(Essentially the VALID dimension in DATA1 is irrelevant and the STAT dimension in DATA2 is irrelevant)
When I do a simple calc of DATA1 * DATA2; no data is returned because when you match the dimensions one measure has data at the leaf level but the other doesn't.
I need to multiply each of the leaf values of the STAT dimension in Measure DATA1 with each leaf value of the VALID dimension in Measure DATA2
Below is an example
Data1
Stat1 Stat2 Stat3 StatTotal
FCO1 10 15 5 -
FCO2 20 25 10 -
FCO3 30 35 15 -
FCOT 60 75 30 -
Data2
Valid1 Valid2 Valid3 ValidTotal
FCO1 1 1 -
FCO2 1 1 -
FCO3 1 1 1 -
Total - - - -
Desired Results:
Valid1 Valid2 Valid3 Valid1 Valid2 Valid3 Valid1 Valid2 Valid3
Stat1 Stat1 Stat1 Stat2 Stat2 Stat2 Stat3 Stat3 Stat3
FCO1 10 10 15 15 5 5
FCO2 20 20 25 25 10 10
FCO3 30 30 30 35 35 35 15 15 15
Total 60 40 50 75 50 60 30 20 25
Does anyone have a suggestion as to what the formula would look like?
Thanks in advanceThe forum tends to change the post and made it difficult to read, but I think I deciphered what you had (putting zeroes in instead of leaving them blank would have helped with the Data2 section).
BTW: Here is how I decoded the data sets you provided (with slight name changes):
Stat1 Stat2 Stat3 StatT Valid1 Valid2 Valid3 ValidT
FCO1 10 15 5 1 1 0
FCO2 20 25 10 1 0 1
FCO3 30 35 15 1 1 1
FCOT 60 75 30
Valid1 Valid2 Valid3 Valid1 Valid2 Valid3 Valid1 Valid2 Valid3
Stat1 Stat1 Stat1 Stat2 Stat2 Stat2 Stat3 Stat3 Stat3
FCO1 10 10 0 15 15 0 5 5 0
FCO2 20 0 20 25 0 25 10 0 10
FCO3 30 30 30 35 35 35 15 15 15
FCOT 60 40 50 75 50 60 30 20 25For future reference, you can copy/paste excel data inside a "code" tag to show it like I did above.
Here is what I would do, assuming I interpreted the need correctly as above:
1) Create a non-aggregating Stat_Input member (in the Valid dimension) to load the first data set.
2) Create a non-aggregating Valid_Input member (in the Stat dimension) to load the second data set.
3) Load the first data set to the new Stat_Input member of the Valid dimension.
4) Load the second data set to the new Valid_Input member of the Stat dimension.
5) Use a calc script to spread the input member to the Stat1/Stat2/State3 members based on Valid1/Valid2/Valid3 values
- Stat1 = Stat_Input * Valid1->Valid_Input;
- Stat2 = Stat_Input * Valid2->Valid_Input;
- Stat3 = Stat_Input * Valid3->Valid_Input;
It may seem confusing to have the Valid_Input in the stat dimension (and vice versa), the point is that this is where the inputs for the respective data goes, and then they are spread to the intersections based on cross-dimensional references that "link" the inputs to the other members. If you were to give the members names based on the current dimension, it would be more confusing because they wouldn't represent the purpose that they serve.
I realize this is likely to generate more questions, but if you can give this approach a try you may find that it isn't as difficult as it seems. -
Multiplying time with number of days in sql
FUNCTION [dbo].[GetTotalSalary1_func]
@emplID int,
@month VARCHAR(50) = NULL
RETURNS int
AS
BEGIN
Declare @BSalaryHour int, @TotalSalary int, @TotalHoursWorked int
Set @TotalHoursWorked = (Select OverallTime from MonthlyRecord where EmplID = @emplID AND Month = @month )
Set @TotalSalary = @BSalaryHour * @TotalHoursWorked
-- Return the result of the function
RETURN @TotalSalary
END
select dbo.GetTotalSalary1_func(5,'2013-dec')
it throws error on this line:
Set @TotalSalary = @BSalaryHour * @TotalHoursWorked
when @totalHoursWorked returned are like this 192:22 or 105:01 i guess bcz it can't multiply :22, :01 part with @BsalaryHour.
so how to do it ?
Note:
OverallTime is basically varchar(13)ok sir it worked but it returns value in whole number like 74 etc but when i use calculator then that returns values like 74.666 etc
Thats because your return type is int for udf.. if you want decimal part also make return type as below and see
USE [a1]
GO
/****** Object: UserDefinedFunction [dbo].[GetTotalSalary1_func] Script Date: 2014-02-20 3:05:17 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER FUNCTION [dbo].[GetTotalSalary1_func]
@emplID int,
@month VARCHAR(50) = NULL
RETURNS float
AS
BEGIN
Declare @StartDate Date, @EndDate Date, @mydate date, @TotalDays int, @TotalHours int,
@BasicSalary int, @BSalaryHour int, @TotalSalary float, @TotalHoursWorked float,
@hms varchar(100),
@hrs int,
@mts int
set @hms = (Select OverallTime from MonthlyRecord where EmplID = @emplID AND Month = @month )
Set @hrs = LEFT(@hms,charindex(':',@hms)-1),@mts=RIGHT(@hms,len(@hms)-charindex(':',@hms))
Set @TotalHoursWorked = @hrs + (@mts/60.0)
Set @mydate = GETUTCDATE()
Set @StartDate = (SELECT CONVERT(VARCHAR(25),DATEADD(dd,-(DAY(@mydate)-1),@mydate),101))
Set @EndDate = (SELECT CONVERT(VARCHAR(25),DATEADD(dd,-(DAY(DATEADD(mm,1,@mydate))),DATEADD(mm,1,@mydate)),101))
Set @TotalDays =((DATEDIFF(dd, @StartDate, @EndDate) + 1)
-(DATEDIFF(wk, @StartDate, @EndDate) * 1)
-(CASE WHEN DATENAME(dw, @StartDate) = 'Sunday' THEN 1 ELSE 0 END))
Set @TotalHours = (@TotalDays * 8)
Set @BasicSalary = (Select BasicSalary from HrEmployee where EmplID=@emplID)
--Set @TotalHoursWorked = (Select OverallTime from MonthlyRecord where EmplID = @emplID AND Month = @month )
Set @TotalSalary = @BSalaryHour * @TotalHoursWorked
Set @BSalaryHour = @BasicSalary / @TotalHoursWorked
-- Return the result of the function
RETURN @TotalSalary
END
select dbo.GetTotalSalary1_func(5,'2013-dec')
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs -
Multiply double with const????
how can I multiply a double with another double, e.g. 1.2345? It does not work, but I can multiply with int. What can I do?
FWIW, I believe there are some classes out there that allow you to format your output and more importantly in the case of money, round appropriately so that they behave well instead of the infamous truncation that ocurrs that can cause people to lose $$ or deutsche marks, etc.
-Felix -
Multiplier problems with SiS648 (6585) mobo
i got a SiS648 (6585) mobo with the lates bios
and a new P4 2.6 gighz (it COULD be a hypertreadering,not sure, but my mobo doesn't support it, so it should just function as a norma cpu)
the problem is, my PC saw it as a 1.3 gighz pc
so i think i should put the fsb to 133 mhz and the multiplier to 19
that should make 2.59
but i can't get the multiplier to go up. i can edit it all i want in the setting but it won't go faster
so now i'm BACK to my old speed of 1.7 gighz with my NEW cpu
any help would be great
thank
RobQuote from: kyoko on 04-March-06, 09:02:21
no no no, the cpu IS a 533 lhz FSB (it's imprinted like that on the cpu itselve)
it would also say if it was a ht -
Collapse multiply layers with different transparency into a single solid filled layer
Hi,
I want to collapse a complex scene with all different layers and different transparency into a single layer (or as few as possible) to optimize the flash file for online (were experince proformance issues).
I have tried the combine and manually copying pasting into one layer but it cuts the fill below and replace with transparent fill. I want to have a end file that is 100% solid.
Is this possible?
Thank you
DarrenYou can create groups and then paste all your groups in a single layer. That won't 'cut' them into each other and the transparency should be maintained. It won't help you with performance though, since the complexity remains the same.
If you have tons of complex vector shapes, it might be a good idea to create a transparent PNG bitmap from illustrator.
That may increase your filesize but it will give you a tremendous performance boost. -
Multiplier 9 with high HTT on MSI NEO4 bugged?
Hi guys,
I have a strange problem with this board.
First my system:
3000+ winnie (No sub-zero bug!)
MSI NEO4 Platinum (Bios 1.2B)
2x512MB GSKILL PC4400
I can run prime stable at 300x9 (180MHz devider).
Under the prometeia I have the oppurtunity to go further.
I hit the 322x9 =2900MHz also prime stable.
http://www.xs4all.nl/~famchow/A64_3.../Prime_2.90.JPG
But after some time, on every moment it give me a BSOD and reboot.
In the bios a max. can set 310MHz in bios to get windows booted, higher I can boot in the bios but reboot before the windows loading screen.
I tryed every settings HTT X1 , 2, 3 and the bandwidth 16/16 8/8. Still nogo.
BUT, when I use MP8, I can boot into windows with HTT 330MHz!!!...
Is this a bios problem or something else?? Maybe this is something for the MSI bios engineers.
THnx
BTW:
to MSI engineers: Check the memory timings settings.
Read preamble, Max async and Trc /Tfrc arent correct when setting. I checked this with A64 tweaker in windows.I have exactly the same problem. No problem with no OC, MemTest-86 and Prime95 ok.
I saw a excellent article on anandtech.com: http://forums.anandtech.com/messageview.aspx?catid=28&threadid=1497607&enterthread=y
First I tries to detect the max HTT/FSB. According to this article I put the CPU multi to 6, the memory to SPD, 2T and memoryclock to 100.
HTT to 4.0. CPU spread spectrum, PCI-e spread spectrum and SATA to disabled. Vcore 1.50V and Vmem 2.60V
FSB 200 en 210 ok. Then FSB 220 the BIOS doesn't start anymore. THe power- and the HDD-led lights continuous and no image on the screen.
I have to reset the BIOS with the button on the board to get back to normal.
I haven't tried Clockgen. As soon as I have results a report back.
My system specs:
BeQuiet Powersupply 400W, +12V 20A
MSI K8N Neo4 Platinum BIOS 1.1
Winchester 3200+
Leadtek Geforce 6600GT
2 x 512MB Crusial Ballistic PC3200
120 Gb Maxtor
Windows XP Pro S2
nVidia nForce4 standalone driver v6.39 -
MOVED: Multiplier 9 with high HTT on MSI NEO4 bugged?
This topic has been moved to Overclockers & Modding Corner. This is the correct area for overclocking stuff. Please take note of that in the future.
https://forum-en.msi.com/index.php?topic=74052.0I have exactly the same problem. No problem with no OC, MemTest-86 and Prime95 ok.
I saw a excellent article on anandtech.com: http://forums.anandtech.com/messageview.aspx?catid=28&threadid=1497607&enterthread=y
First I tries to detect the max HTT/FSB. According to this article I put the CPU multi to 6, the memory to SPD, 2T and memoryclock to 100.
HTT to 4.0. CPU spread spectrum, PCI-e spread spectrum and SATA to disabled. Vcore 1.50V and Vmem 2.60V
FSB 200 en 210 ok. Then FSB 220 the BIOS doesn't start anymore. THe power- and the HDD-led lights continuous and no image on the screen.
I have to reset the BIOS with the button on the board to get back to normal.
I haven't tried Clockgen. As soon as I have results a report back.
My system specs:
BeQuiet Powersupply 400W, +12V 20A
MSI K8N Neo4 Platinum BIOS 1.1
Winchester 3200+
Leadtek Geforce 6600GT
2 x 512MB Crusial Ballistic PC3200
120 Gb Maxtor
Windows XP Pro S2
nVidia nForce4 standalone driver v6.39 -
Multiply Currency with exchange rate Prorblem
Hi All,
data: p_value type komvd-kwert.
This is my code in my progam
CALL FUNCTION 'READ_EXCHANGE_RATE'
EXPORTING
date = sy-datum
foreign_currency = 'EUR'
local_currency = 'GBP'
TYPE_OF_RATE = 'M'
IMPORTING
exchange_rate = l_exchng_rate
foreign_factor = l_foregin_fac
local_factor = l_local_fac
valid_from_date = l_valid_fdat
EXCEPTIONS
no_rate_found = 1
no_factors_found = 2
no_spread_found = 3
derived_2_times = 4
overflow = 5
zero_rate = 6
OTHERS = 7.
IF sy-subrc EQ 0.
g_erate = l_exchng_rate / ( l_foregin_fac / l_local_fac ).
p_value = p_value * g_erate.
when i debug program values are p_value = 66.66, g_erate = 0.67840
but when i multifly this i am getting 45222144 instead of 45.222144.
could anybody tell me why it is coming like this...Hello,
It occurs because in your program attributes you don't flag the option Fixed point arithmetic .
Regards. -
In Javascript I suggest multiplying the text field by 1 to change it to a numeric type then multiply this with the other numeric field. The code would look something like:
Total.rawValue = numericField.rawValue * (textField.rawValue*1) -
Can you help me with a Cost problem in an Order?
Hello SAP experts, i have a question regarding orders and their costs if i go inside an order and i go to the menu then ->Goto->Costs->Analisys-> and then choose the layout ->Target/Actual Comparison, in this layout there is a column that says
Total Target Cost and Total actual cost, i would like to know is what data does the system use to calcule those values, i know that one value is the amount of material that was charged to the order, but i would like to know from where does it take the other value the cost value so it can reach that number, thank you in advanceHi,
In simple words:
Target cost = Plan price * Actual qty
Actual cost = Actual price * Actual qty
Now where does the price come from... it depends on the valuation variant which is used for the order type. Normally it is the standard price from the material master which you can see in Accounting - 1 view or Costing - 2 view.
The actual quantity is the qty of a component which has been issued to that order.
So to get a clear picture, take a material which you see in the cost analysis view of that order & open the material master. Check the price for that part, multiply it with the qty issued & your query should be clarified.
Revert if you face any issues.
Regards,
Vivek -
Printing value fields with negative sign??
Hello Experts,
I have developed a interface, which writes the invoice data to application server/unix, this is a notepad. My specifications are as below,
MWSK1(2) TaxCode 65 2 KONV-MWSK1
KWERT(13) Condition Value 67 13 KONV-KWERT
KSTEU(1) Condition Control 80 1 KONV-KSTE
I have to print KWERT value from 67th position until 13 positions, meaning until 80 positions, fine. My code is as below,
MOVE: wa_invoice_price-mwsk1 TO unix_file+64(2).
WRITE: wa_invoice_price-kwert TO unix_file+66(13) RIGHT-JUSTIFIED.
MOVE: wa_invoice_price-ksteu TO unix_file+79(1),
So, it printing like below (pls. note 0.04 minus value in right bottom corner)
P26701ZCG620101006C 100.00 0.00USD 1 UGL 0.00A A 9
P60001ZF3520101006C 100.00 0.00USD 1 UGLG 0.04-H B 9
But, business want to have like below (pls. note the DIFFERENCE for 0.04 minus value in right bottom corner),
P26701ZCG620101006C 100.00 0.00USD 1 UGL 0.00 A A 9
P60001ZF3520101006C 100.00 0.00USD 1 UGLG 0.04 - H B 9
meaning, the 13th position should be negative sign (if at all any value does have a negative sign, else its normal)....so, the negative sign should sit on 13th postion. As am using WRITE statement with RIGHT JUSTIFIED am facing thisissue!! as u know we can not send a 'P' type value to unix/apps server, pls. let me know how to get it done?
Thank youwhy can't the user live with a leading sign, like '- 0.04'? If possible, do
shift <fieldname> circular up to '-'.
Or, if value is less than zero, set another variable to '-', else set to space, and multiply value with '-1', like:
if <field> < 0.
lv_sign = '-'. " neagtive value
<field> = <field> * '-1'. "reverse the sign
else.
lv_sign = space. "positive value
endif.
then, adjust your field length and insert a sign column or simply add a column for the sign.... -
Problem with a SQL query involving dates
I have a database with each task made by a developer in the company's systems, with 2 fields to determine the duration of the tasks: begin_date and end_date, both Dates. Now I have to make an SQL query returning the total of hours each one worked counting every task, so I'm using something like this (simplifying):
select user_id, sum(end_date - begin_date)
from task
group by user_id
but I get a weird fractional number. How do I do this query?What database are you using? Oracle?
The weird fractional number is probably the difference between the dates in days. If you want it in hours, try multiplying it with 24.
select user_id, sum(end_date - begin_date) * 24
from task
group by user_id
Maybe you are looking for
-
I really need some help here. I would like to say the APPLE staff has been helpful for me, but I am very disappointed in the "service" I have received. I have tried to reset my password, I have taken my phone to APPLE, they were rude and were no hel
-
How do I move (not backup) purchased Apps?
Hi there I sent this question to Support earlier but they directed me to Applecare for an answer... Hopefully someone here might be able to help - thanks in advance! I've been using the Mac App Store since launch. I run my machine with a smallish SSD
-
Best way to copy from an External HD to TimeCapsule's internal HD?
Hi, I have a USB 2.0 connectable external drive (powered) that's full of files I'd like to copy over to my TimeCapsule's internal drive. If I connect the USB to my Mac and copy the files by selecting them all and dragging them to the mounted share on
-
Some .htm file not displaying in Topic List, but displaying in RH11 folder
Hi All, We are running a project using RH 11, team consist of 3 person (include me) But we have problem with many .htm file from my 1st coworker, file not displaying in Topic List in my Robohelp and 2nd coworker. Although we already get the latest f
-
ITunes keeps creating duplicate m4p files for existing m4a files
I noticed in 10.0 that I had duplicates of many of my purchased music, an m4a and an m4p. I tried removing the m4p files through iTunes, and through Finder. I have used the Display Exact Duplicate to identify some of them and then removed them. But a