Received: by 10.101.34.2 with SMTP id m2mr31024anj.2.1250089948938; Wed, 12 Aug 2009 08:12:28 -0700 (PDT)Date: Wed, 12 Aug 2009 08:12:28 -0700 (PDT)X-IP: 204.52.177.2User-Agent: G2/1.0X-Google-Token: QFSVaQwAAABl4FTrAHciST9QVxpRTEBLX-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729),gzip(gfe),gzip(gfe)Message-ID: <2e64156b-61c2-496a-9363-9466e91ce456@33g2000vbe.googlegroups.com>Subject: column aliasFrom: Ninja Li To: “Kdb+ Personal Developers” Cc: ningli2000@hotmail.comX-Google-Approved: charlie@kx.com via web at 2009-08-12 15:13:12Hi, I am now to Kx. I would like to know how I can give an alias to acolumn, e.g. ($name) in the following query: select index, (
$name) from symuniv where ($name)<>
Thanks in advance. Ning
X-Mailer: Apple Mail (2.935.3)On Aug 12, 2009, at 11:12 PM, Ninja Li wrote:> I am now to Kx. I would like to know how I can give an alias to a > column, e.g. ($name) in the following query:\>\> select index, (
$name) from symuniv where ($name)\<\>
do you mean a query where the column name is stored in a variable?there’s two ways to do that:either use a functional queryq)?[symuniv;enlist(<>;$name;enlist
);0b;index
sym!index
sym]or construct and evaluate the code:q)get"select index,“,name,” from symuniv where “,name,”<>`"the first is a bit harder to get your head around as a new user, but is ultimately much more flexible and maintainable
Thanks for the help.On Aug 12, 11:32?am, Aaron Davies <aaron.dav…> wrote:> On Aug 12, 2009, at 11:12 PM, Ninja Li wrote:>> > I am now to Kx. I would like to know how I can give an alias to a ?> > column, e.g. ($name) in the following query:>> > select index, (
$name) from symuniv where ($name)<>
>> do you mean a query where the column name is stored in a variable?>> there’s two ways to do that:>> either use a functional query>> q)?[symuniv;enlist(<>;$name;enlist
);0b;index
sym!index
sym]>> or construct and evaluate the code:>> q)get"select index,“,name,” from symuniv where “,name,”<>`">> the first is a bit harder to get your head around as a new user, but ?> is ultimately much more flexible and maintainable</aaron.dav…>