Data manipulation using compounded column data

I am having some difficulty using the cor function using compounded
column data from a table.

If someone could please explain where I am going wrong on this
simplified example it would be much appreciated.

// Example Data
q)x:(stockclose)!(aaabbb`ccc;(1 2 3 4;5 6 7 8;9 10 11 12))
q)y:flip x
q)y
stock close

aaa 1 2 3 4
bbb 5 6 7 8
ccc 9 10 11 12

q)y[close][0] cor y[close][0]
1f
q)a:exec i from y where stock=aaa q)a ,0 q)y[close][a]
1 2 3 4
q)y[close][a] cor y[close][a]
k){avg x*x-:avg x}
'length

Perfuming the operation by selecting the data also returns a length
error,

q)a:exec close from y where stock=`aaa
q)a cor a
k){avg x*x-:avg x}
'length

Thanks

x is a nested table

q)type y[close][a] 0h q)type y[close][0]
6h
q)a:exec close from y where stock=3D`aaa
q)first[a]
1 2 3 4
q)first[a]cor first[a]
1f
q)select {x cor x} each close from x
close

1
1
1