page.ts
price = 300,residential_package = 120, accompany = 1335;
this.delegates_total = this.price + this.residential_package + this.accompany;
result shows 3001201335
I want to add these fields value but it doesn't give me correct result please tell me where m going wrong and thank you for your help
use Number() to convert to number and then use +;
Or you can use + to convert to number like +this.price;
price = 300,residential_package = 120, accompany = 1335;
this.delegates_total = Number(this.price) + Number(this.residential_package) + Number(this.accompany);
in your case you are concatenate 3 strings
declare your fields with type
price:number=300
residential_package:number=120
accompany:number=1335
Related
Just want to get an idea & advise.. how to get the exact result for my situation when query..see below table..
I try to use this query and its look fine..but the problem is when I give the input ABC1001Z (different only last character Z).. the query still return Honda as result.. it's supposed not return any result/no result found.. any solution for my case?
SELECT Name
FROM CarNo
WHERE ('ABC1001Z' BETWEEN Start AND End)
AND (len('ABC1001Z') = len (Start));
Your kind support is much appreciated..
Update you code to
SELECT Name FROM CarNo
WHERE (SUBSTRING('ABC1001Z',0,7) BETWEEN SUBSTRING(Start,0,7) AND SUBSTRING(End,0,7) )
AND (len('ABC1001Z') = len (Start));
Maybe that's what you are looking for:
SELECT Name FROM CarNo
WHERE (Start = 'ABC1001Z' OR End = 'ABC1001Z')
AND (len('ABC1001Z') = len(Start));
You seem to want the "number" in the middle to be treated as a number. This suggests something like this:
where left('ABC1001Z', 3) between left(start, 3) and left(end, 3) and
substr('ABC1001Z', 4, 4) + 0 between substr(start, 4, 4) + 0 and substr(end, 4, 4) + 0
I'm not sure how the last character relates to a between query of this form, so I'm not addressing that.
def compute_invigilated_mark():
"""Prints given name and family name with overall score"""
test = 0.15
exam = 0.60
first_name = input("Given names(s)? ")
last_name = input("Family name? ")
both_names = last_name.upper() + "," + first_name.title()
new_test_percent = float(input("Test percent? ")) * test
new_exam_percent = float(input("Exam percent? ")) * exam
overall_percent = new_test_percent + new_exam_percent
end_result = overall_percent / (exam + test)
print(both_names + end_result)
compute_invigilated_mark()
I want to get the end result of, For example: Bourne, Jason: 66.0
The rrror message:
builtins.TypeError: Can't convert 'float' object to str implicitly.
NB: I spaced it out like this so you could read it easier :).
both_names is a string and end_result is a float, yet you are trying to add\concat them together (print(both_names + end_result)).
You should convert end_result to a string:
print(both_names + str(end_result))
source:
constant x,y,
mysql table named 'table1'. It contains column pp.
Need change all values in table1:
pp_new = pp/x*y;
pp_new = round(pp_new) to 0.1.
For example 12.31 = 12.30, 14.56 = 14.50, 55.1245035 = 55.10
12.31 = 12.30, 14.56 = 14.50, 55.1245035 = 55.10
You need to use truncate(number,decimalplaces)
TRUNCATE(1.25864,1)
this will return 1.2
What about something like UPDATE table1 SET pp = round(pp/x*y) ?
There are two types of records in my Db such as MS-NW and CS in the same column of table DICIPLINE I want to wrap if its CS (ANY TWO STRING LIKE CS,TE OR THE LIKE) then wrap it to BS(CS) (OR BS(TE) ETC) or if its MS-NW (Or MS-CS, MS-TE and the like) then wrap it to MS(NW) from the column dicipline.
I updated for two strings successfully and following is the query for that kindly let me know how can i do it for values like MS-NW OR MS-CS and convert it to the format like MS(NW) from following query .
UPDATE DEG set DICIPLINE = concat("BS(",DICIPLINE,")") where CHAR_LENGTH(DICIPLINE) = 2
The below query helps you to update your data.
update deg set DISIPLINE = if(length(DISIPLINE)= 2,concat('BC(',DISIPLINE,')')
,concat('MS(',substr(DISIPLINE, 4,4),')'));
See Sqlfiddle demo.
For safety, create a temporary column of same type and perform an update like this:
UPDATE deg
SET dicipline_temp = CASE
WHEN CHAR_LENGTH(dicipline) = 2
THEN CONCAT('BS(', dicipline, ')')
WHEN CHAR_LENGTH(dicipline) = 5 AND SUBSTRING(dicipline, 3, 1) = '-'
THEN CONCAT(REPLACE(dicipline, '-', '('), ')')
END
WHERE CHAR_LENGTH(dicipline) = 2 OR (CHAR_LENGTH(dicipline) = 5 AND SUBSTRING(dicipline, 3, 1) = '-')
If results are acceptable, update the actual column.
i think this one is simple but i cant find a good example.
What i have is three columns. StartPrice EndPrice Dividens and results. Each of these is a decimal(10,2) column in MySql. What i'm looking for is (preferably) is an update statement that basically will do Dividens / (AddPrice + EndPrice) and return the decimals.
Example:
Dividens (AddPrice + Endprice) = result
2.09 / (7.52 + 10.52) = .11
7.40 / (1.75 + 1.25) = 2.47
All columns are decimal(10,2)
I'm looking for basically
update tblmath
set result = '<this is what i cant do>
where result = null
Assuming your table is called tblmath and you're trying to update a column called result to contain the result of the calculation, this should work for you:
update tblmath set result = Dividens / (AddPrice + Endprice) where result is null;
BTW: You misspelled "Dividends", but I preserved the misspelling in the SQL above.