Hi, Dear all:
Do you know how to add the percent sign(%) into the dataset?
For example, the qsql is: select name, 100*(Last-Open)%Open from price
Thanks
Zheng
Hi, Dear all:
Do you know how to add the percent sign(%) into the dataset?
For example, the qsql is: select name, 100*(Last-Open)%Open from price
Thanks
Zheng
Hey Zheng,
If i’ve interpretted your question correctly, perhaps you are looking for something like this? There’s probably a more efficient way to do this however.
q)select sym, pct:({x,“%”} each exec string(100*(ask-bid)%bid) from quotes) from quotes
sym pct
NOK “0%”
AAPL “0.1182499%”
ORCL “0.06236358%”
GOOG “0.09751341%”
IBM “0.09210223%”
Fitting your query, something like this: (colname is whatever you’d like to name your percentage column)
q)select name, colname:({x,“%”} each exec string(100*(Last-Open)%Open from price) from price
Kind regards,
Matt
Hey Zheng,
Here’s an updated and more efficient way to perform your query(ignore the negative fields, as it’s just test data):
q)testtable
Last Open name
19 12 Test
6 14 Test
12 11 Test
q)update pctfield:((string 100*(Last-Open)%Open),:“%”) from testtable
Last Open name pctfield
19 12 Test “58.33333%”
6 14 Test “-57.14286%”
12 11 Test “9.090909%”
Kind Regards,
Matt
Hi, Matt:
Yes, agree with you there’re always more solutions than problem itself.
I read and used your method, and it works to resolve my problem.
Thanks very much! Have a nice day!
Thanks
Zheng