using type inside select

Hi,Trying to use the ‘type’ function inside the select, but it doesn’twork: q)t:( c:ab) q)select type c from t 'typeCan you please help understand why I get the error?Thanks,Petru

X-Mailer: Apple Mail (2.936)On Apr 2, 2010, at 9:43 AM, petrum wrote:> q)t:( c:ab)> q)select type c from t> 'typei think the problem is that it returns the equivalent of (c:11h), which is invalid due to being an atomtry these insteadq)select enlist type c from tc–11orq)exec type c from t11h

Please try

select each[type] c from t

Wei

2010/4/2 petrum <petru.marginean>:
> Hi,
>
> Trying to use the ‘type’ function inside the select, but it doesn’t
> work:
>
> =A0 =A0q)t:( c:ab)
> =A0 =A0q)select type c from t
> =A0 =A0’type
>
> Can you please help understand why I get the error?
>
> Thanks,
> Petru
>
> –
>

Submitted via Google Groups</petru.marginean>

or, if you just want to know the particular type of a certain column,

q)tab:( c1:ab; c2:1 2)
q)exec first t from meta tab where c=3Dc1 "s" q)exec first t from meta tab where c=3Dc2

Wei

2010/4/2 =BA=CE=CE=A1 <hewei.com>:
> Please try
>
> select each[type] c from t
>
> Wei
>
> 2010/4/2 petrum <petru.marginean>:
>> Hi,
>>
>> Trying to use the ‘type’ function inside the select, but it doesn’t
>> work:
>>
>> q)t:( c:ab)
>> q)select type c from t
>> 'type
>>
>> Can you please help understand why I get the error?
>>
>> Thanks,
>> Petru
>>
>> –
>> You received this message because you are subscribed to the Google Group=
s “Kdb+ Personal Developers” group.
>> To post to this group, send email to personal-kdbplus@googlegroups.com.
>> To unsubscribe from this group, send email to personal-kdbplus+unsubscri=
be@googlegroups.com.
>> For more options, visit this group at http://groups.google.com/group/per=
sonal-kdbplus?hl=3Den.
>>
>>
>

</petru.marginean></hewei.com>

Should “type” and “count” behave in similar ways?q)select count c from tc-2q)select type c from t’typeq)exec count c from t2q)exec type c from t11hq)type exec count c from t-6hq)type exec type c from t-5hI incorrectly assumed both “type” and “count” would work in similarway. I’m not familiar enough with k to know weather the k definitionhas any significance.q)type@:q)count#:On Apr 2, 9:50?am, Aaron Davies <aaron.dav…> wrote:> On Apr 2, 2010, at 9:43 AM, petrum wrote:>> > ? ?q)t:( c:ab)> > ? ?q)select type c from t> > ? ?'type>> i think the problem is that it returns the equivalent of (c:11h), ?> which is invalid due to being an atom>> try these instead>> q)select enlist type c from t> c> –> 11>> or>> q)exec type c from t> 11h</aaron.dav…>

How come this works (count instead of type): q)select count c from t c - 2Regards,PetruOn Apr 2, 9:50?am, Aaron Davies <aaron.dav…> wrote:> On Apr 2, 2010, at 9:43 AM, petrum wrote:>> > ? ?q)t:( c:ab)> > ? ?q)select type c from t> > ? ?'type>> i think the problem is that it returns the equivalent of (c:11h), ?> which is invalid due to being an atom>> try these instead>> q)select enlist type c from t> c> –> 11>> or>> q)exec type c from t> 11h</aaron.dav…>

I think the funcs like count/first/last/sum/avg/dev etc are specially
treated and always return a list.

For example:
q)select type c,count c from t
c c

11 2

is similar to:
q)( a:enlist 1;b:2)
a b

1 2

X-Mailer: Apple Mail (2.936)On Apr 2, 2010, at 6:27 PM, Xi Chen wrote:> I think the funcs like count/first/last/sum/avg/dev etc are specially> treated and always return a list.looks like they’re magically munged to work as tablesstrategically inserting 0N!'s allows you to see (some of) what’s going onq)select 0N!type c from t11h’typeq)select 0N!count c from t2c-2it occurred to me that it might be specific to ints, but no:q)select 0N!“i”$type c from t11’type

Many thanks for helping to understand this…

Strangely this works:

q)select type count c from t
c

-6

Petru