Hi,
given two keyed tables, both with different keys, is it possible to join based on named columns, where column names may differ? Here’s a slightly verbose example:
q)balances:([Account:
SmithJones;Currency:
USDEUR]Balance:(0.10f;0.20f))q)balancesAccount Currency| Balance----------------| -------Smith USD | 0.1Jones EUR | 0.2q)offers:([Account:
SmithSmith
Jones;Sequence:(0;1;0)]TakerGetsAmount:(0.01;0.011;0.12);TakerGetsCurrency:USD
USDEUR;TakerPaysAmount:(0.015;0.016;0.017);TakerPaysCurrency:
EURUSD
USD)q)offersAccount Sequence| TakerGetsAmount TakerGetsCurrency TakerPaysAmount TakerPaysCurrency----------------| -------------------------------------------------------------------Smith 0 | 0.01 USD 0.015 EURSmith 1 | 0.011 USD 0.016 USDJones 0 | 0.12 EUR 0.017 USDq)ej[Account
TakerGetsCurrency;offers;balances]k){x,:();y[&#:‘i],’(x_z)(!0),/i:(=x#z:0!z)x#y:0!y}'TakerGetsCurrency#Account
TakerGetsCurrency+Account
CurrencyBalance!(
SmithJones;
USDEUR;0.1 0.2)q.q))
I’d like to get the available balance for each offer by using a join key of Account and TakerGetsCurrency, but the join fails because TakerGetsCurrency in the offers table and Currency in the balances table have different names. Thanks for any help!
Cheers,
Donovan.