selecting single element from a list

Hi,

I wonder if there is a way to select a single element from a list, for example…

date       time         prc  vol     bPrc1                   


2014.01.02 09:25:05.000 9.44 1461700 9.43 9.42 9.41 9.4  9.39

2014.01.02 09:30:02.000 9.4  111300  9.39 9.38 9.37 9.36 9.35

2014.01.02 09:30:05.000 9.4  185400  9.39 9.38 9.37 9.36 9.35

2014.01.02 09:30:09.000 9.4  10500   9.39 9.38 9.37 9.36 9.35

2014.01.02 09:30:15.000 9.4  200     9.39 9.38 9.37 9.36 9.35

q)select bPrc: bPrc1[0] from tb

bPrc


9.43

9.42

9.41

9.4 

9.39

^^^^^^^

That is probably not what I want.

q)(flip tb[`bPrc1])[0]

9.43 9.39 9.39 9.39 9.39 9.37 9.37 9.37 9.38 9.38 9.38 9.38 9.38 9.38 9.37 9…

The only method I can think of is, flip the entire list, and put it back.

could anyone suggest a better method?

Thanks

Gary

exec

0925fd46-5d6a-4394-955f-9cefd96d38d8@googlegroups.com>To: Gary Chow , Kdb+ Personal Developers

Try either:

select bPrc1[;0] from tb
select first each bPrc1 from tb

Or if you want a list not a table, use exec as Attila suggested.

David


From: Gary Chow

Sent: Friday, March 11, 2016 03:06
To: Kdb+ Personal Developers
Reply To: personal-kdbplus@googlegroups.com
Subject: [personal kdb+] selecting single element from a list

Hi,

I wonder if there is a way to select a single element from a list, for example...

date time prc vol bPrc1
-------------------------------------------------------------
2014.01.02 09:25:05.000 9.44 1461700 9.43 9.42 9.41 9.4 9.39
2014.01.02 09:30:02.000 9.4 111300 9.39 9.38 9.37 9.36 9.35
2014.01.02 09:30:05.000 9.4 185400 9.39 9.38 9.37 9.36 9.35
2014.01.02 09:30:09.000 9.4 10500 9.39 9.38 9.37 9.36 9.35
2014.01.02 09:30:15.000 9.4 200 9.39 9.38 9.37 9.36 9.35

q)select bPrc: bPrc1[0] from tb
bPrc
----
9.43
9.42
9.41
9.4
9.39

^^^^^^^
That is probably not what I want.

q)(flip tb[`bPrc1])[0]
9.43 9.39 9.39 9.39 9.39 9.37 9.37 9.37 9.38 9.38 9.38 9.38 9.38 9.38 9.37 9...

The only method I can think of is, flip the entire list, and put it back.
could anyone suggest a better method?

Thanks

Gary

--

Submitted via Google Groups

Thanks David and Attila,

I think bPrc1[;0] sounds more intuitive for me. And it actually remind me that in this case, bPrc1 is a 2D array.

Gary