kind of join

Hello Gurus,

I am facing an issue to join 2 tables. Below is me requirement.

q)t2:(ticker:10?IBMGOOG`MSFT;time2:10?.z.t;sellP:10?10.0;vol2:10?10)

q)t1:(ticker:10?IBMGOOG`MSFT;time1:10?.z.t;buyP:10?10.0;vol:10?10)

I have above 2 tables:

t1 :

tickertime1buyPvol

GOOG01:48:39.3334.844727010931825

GOOG04:59:16.7641.53226961381733423

GOOG03:07:01.5885.3509228024631749

GOOG04:56:25.0104.5732803782448175

GOOG00:24:51.8864.8615462007001044

IBM04:07:07.5951.03934334823861727

MSFT03:46:36.1096.8279990367591382

MSFT02:06:39.0130.08062521461397419

MSFT03:22:49.9171.04451174149289736

MSFT06:28:41.2393.38009702507406476

t2 :

tickertime2sellPvol2

GOOG05:50:50.4636.4309822791256018

GOOG04:58:27.0483.8673530425876383

GOOG01:23:46.2818.355064962524928

IBM03:46:37.6777.2678099689073863

IBM02:31:11.0380.36683407146483667

IBM02:13:45.2756.7087377328425655

IBM01:06:15.8906.789082442410296

MSFT05:31:58.2554.1231701336801054

MSFT01:53:56.1229.8778444156050681

MSFT01:04:08.7424.0465459413826477

I want to join t1 and t2 side by side depending on ticker.

uj with ticker as key will not work as it interprets the key to be unique.

my final table should look like this

| ticker | time1 | buyP | vol | time2 | sellP | vol2 |
| GOOG | 01:48:39 | 4.844727 | 5 | 05:50:50 | 6.430982 | 8 |
| GOOG | 04:59:17 | 1.53227 | 3 | 04:58:27 | 3.867353 | 3 |
| GOOG | 03:07:02 | 5.350923 | 9 | 01:23:46 | 8.355065 | 8 |
| GOOG | 04:56:25 | 4.57328 | 5 | | | |
| GOOG | 00:24:52 | 4.861546 | 4 | | | |
| IBM | 04:07:08 | 1.039343 | 7 | 02:31:11 | 0.366834 | 7 |
| IBM | | | | 02:13:45 | 6.708738 | 5 |
| IBM | | | | 01:06:16 | 6.789082 | 6 |
| IBM | | | | 03:46:38 | 7.26781 | 3 |
| MSFT | 03:46:36 | 6.827999 | 2 | 05:31:58 | 4.12317 | 4 |
| MSFT | 02:06:39 | 0.080625 | 9 | 01:53:56 | 9.877844 | 1 |
| MSFT | 03:22:50 | 1.044512 | 6 | 01:04:09 | 4.046546 | 7 |
| MSFT | 06:28:41 | 3.380097 | 6 | | |
|

Thanks

Rajesh

It’s hard to infer a logic from your sample data.
The obvious way would be to join using aj and having tables ticker+time sorted.

One way:

 

ungroup((lj).`ticker xgroup/:(t1;t2))@:‘til each get max{exec count i by ticker from x}@’(t1;t2)