cancel
Showing results for 
Search instead for 
Did you mean: 

Functional a multi-condition query

hzadonis369
New Contributor III

Hi, Masters:

  I have a litter bit complex qSql, for example:

select CntCOMP:count IND, avg Grade, COMP by IND, OptDate from (`IND xasc select RIC, COMP:link.COMPANY, BuySell, OptDate, OptPrice, Grade, Comment, IND:link.IND, LOC:link.LOC from AShare_Position where OptDate within ((`month$2022.04.30), 2022.04.30), StrategyID = `$"MTH002") where IND = `$"银行"

 It works fine. Then, I need embed it into a function and execute it with flying parameters. So I defined:

theDateIWant: 2022.04.30
stgid: `$"MTH002"
ind_name: `$"银行"

and parse it:

parse "select CntCOMP:count IND, avg Grade, COMP by IND, OptDate from (`IND xasc select RIC, COMP:link.COMPANY, BuySell, OptDate, OptPrice, Grade, Comment, IND:link.IND, LOC:link.LOC from AShare_Position where OptDate within ((`month$theDateIWant), theDateIWant), StrategyID =`stgid) where IND = `ind_name"

Output is:

?
(k){$[$[#x;~`s=-2!(0!.Q.v y)x;0];.Q.ft[@[;*x;`s#]].Q.ord[<:;x]y;y]};,`IND;(?;`AShare_Position;,((within;`OptDate;(,;($;,`month;`theDateIWant
);`theDateIWant));(=;`StrategyID;,`stgid));0b;`RIC`COMP`BuySell`OptDate`OptPrice`Grade`Comment`IND`LOC!`RIC`link.COMPANY`BuySell`OptDate`Opt
Price`Grade`Comment`link.IND`link.LOC))
,,(=;`IND;,`ind_name)
`IND`OptDate!`IND`OptDate
`CntCOMP`Grade`COMP!((#:;`IND);(avg;`Grade);`COMP)

But it always has error once I execute it with functional query, one of my ill-samples is:

`IND xasc eval(?;`AShare_Position;,((within;`OptDate;(,;($;,`month;`theDateIWant);`theDateIWant));(=;`StrategyID;`stgid));0b;`RIC`COMP`BuySell`OptDate`OptPrice`Grade`Comment`IND`LOC!`RIC`link.COMPANY`BuySell`OptDate`OptPrice`Grade`Comment`link.IND`link.LOC)),,(=;`IND;`ind_name)`IND`OptDate!`IND`OptDate`CntCOMP`Grade`COMP!((#:;`IND);(avg;`Grade);`COMP)

It looks like the ",," is not right. I used to met this issue with single condition query, it can be resolved to replace "," with "enlist". But this time, "enlist" or even double "enlist" to replace "," doesn't work.

So, dear masters, do you know how to debug it? Appreciate for any advice, thanks!

 

  

0 REPLIES 0