Advanced Capstone 2.5

I am trying to convert the following into a functional select as I have done in the past but cant seem to get any of the conditions working. 

 

symbols:windSpeedFronttempBackLeft`tyrePressureBackLeft;
select from sensor where 0=lapId mod 2,sensorId in symbols,date in 2020.01.01 2020.01.02

 

For example :

?[sensor;enlist (in;`date;enlist (2020.01.01)) ;0b;()]  and

?[sensor;enlist (=;``lapId mod 2;0) ;0b;()]   both return mismatch errors

 

 

q)show sensor:(lapId:10?100;sensorId:10?foobar,symbols;date:10?2020.01.01+til 3) lapId sensorId date ------------------------------------- 40 bar 2020.01.01 88 foo 2020.01.01 77 windSpeedFront 2020.01.03 30 tyrePressureBackLeft 2020.01.02 17 bar 2020.01.03 23 windSpeedFront 2020.01.02 12 foo 2020.01.03 66 bar 2020.01.03 36 bar 2020.01.02 37 windSpeedFront 2020.01.01 q)select from sensor where 0=lapId mod 2,sensorId in symbols,date in 2020.01.01 2020.01.02 lapId sensorId date ------------------------------------- 52 windSpeedFront 2020.01.01 66 tyrePressureBackLeft 2020.01.01 24 tyrePressureBackLeft 2020.01.01 62 tempBackLeft 2020.01.02 q)?[sensor;enlist (in;`date;enlist (2020.01.01)) ;0b;()] lapId sensorId date ------------------------------------- 52 windSpeedFront 2020.01.01 66 tyrePressureBackLeft 2020.01.01 24 tyrePressureBackLeft 2020.01.01 59 windSpeedFront 2020.01.01 q)?[sensor;enlist (=;lapId mod 2;0) ;0b;()] 'type [0] ?[sensor;enlist (=;lapId mod 2;0) ;0b;()] ^

 

Not seeing your mismatch errors. What am I missing?

The third argument of Select ? is a list of constraints. Each constraint is a parse tree. Table columns are referenced by their names as symbols.

q)/ constrain date q)?[sensor;enlist (in;date;2020.01.01+0 1) ;0b;()] lapId sensorId date ------------------------------------- 52 windSpeedFront 2020.01.01 66 tyrePressureBackLeft 2020.01.01 24 tyrePressureBackLeft 2020.01.01 62 tempBackLeft 2020.01.02 95 foo 2020.01.02 59 windSpeedFront 2020.01.01 82 bar 2020.01.02 q)/ constrain sensorIDs too q)?[sensor;((in;date;2020.01.01+0 1);(in;sensorId;symbols)) ;0b;()] lapId sensorId date ------------------------------------- 52 windSpeedFront 2020.01.01 66 tyrePressureBackLeft 2020.01.01 24 tyrePressureBackLeft 2020.01.01 62 tempBackLeft 2020.01.02 59 windSpeedFront 2020.01.01 q)/constrain lapIDs as well q)?[sensor;((in;date;2020.01.01+0 1);(in;sensorId;symbols);(=;0;(mod;lapId;2))) ;0b;()] lapId sensorId date ------------------------------------- 52 windSpeedFront 2020.01.01 66 tyrePressureBackLeft 2020.01.01 24 tyrePressureBackLeft 2020.01.01 62 tempBackLeft 2020.01.02 q)

Thanks for this, I reloaded my HDBs and this worked for me, I might of altered them somewhere along the way which changed a type.