Received: by 10.101.75.4 with SMTP id c4mr360827anl.28.1257533982724; Fri, 06 Nov 2009 10:59:42 -0800 (PST)Date: Fri, 6 Nov 2009 10:59:42 -0800 (PST)X-IP: 66.102.123.102User-Agent: G2/1.0X-Google-Token: qmH58AwAAABMAo2eIMBU8_0ndzGEBeh3X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1b99) Gecko/20090605 Firefox/3.5b99 (.NET CLR 3.5.30729),gzip(gfe),gzip(gfe)Message-ID: <57d7bc4d-e320-4abd-988c-fcfcb1f4f808@o10g2000yqa.googlegroups.com>Subject: Newb guidance - trying to learn to fishFrom: pphillips99 To: “Kdb+ Personal Developers” X-Google-Approved: charlie@kx.com via web at 2009-11-06 19:09:27I’ve scoured over quite a bit of the kx.com docs and the forum here(google seems woefully inadequate – k q kdb ksql are pretty toughqueries) and I feel like I need to make some kind of paradigm shift inmy head in order to understand.I can invent this in Q:select ticker, date price, avg4:4 mavg price by ticker from datawhich producesABC date date date date price price price price …DEF date date date date price price price price …but I have this query result in my head :ABC date price avgABC date price avgABC date price avgABC date price avgDEF date price avgDEF date price avgDEF date price avgDEF date price avgHow can I change/rewrite the Q query?Where can I read more about comparing my traditional RDBMSsensibilities to K/Q/KDB methods?I really want to believe and this tool seems capable of anything.P
Date: Fri, 6 Nov 2009 14:25:08 -0500Message-ID: Subject: Re: [personal kdb+] Newb guidance - trying to learn to fishFrom: Fintan Quill To: personal-kdbplus@googlegroups.comHello,Remove the “by” clause from your query. The by clause is similar tothe “group by” clause in SQL, except neater & more intuitive.select ticker, date, price, avg4:4 mavg price from dataThe file s.k in the trial distribution will give you comparisons with SQL.Regards,Fintan.On Fri, Nov 6, 2009 at 1:59 PM, pphillips99 wrote:>> I’ve scoured over quite a bit of the kx.com docs and the forum here> (google seems woefully inadequate – k q kdb ksql are pretty tough> queries) and I feel like I need to make some kind of paradigm shift in> my head in order to understand.>>> I can invent this in Q:>> select ticker, date price, avg4:4 mavg price by ticker from data>> which produces>> ABC date date date date price price price price …> DEF date date date date price price price price …>> but I have this query result in my head :>> ABC date price avg> ABC date price avg> ABC date price avg> ABC date price avg> DEF date price avg> DEF date price avg> DEF date price avg> DEF date price avg>> How can I change/rewrite the Q query?> Where can I read more about comparing my traditional RDBMS> sensibilities to K/Q/KDB methods?>> I really want to believe and this tool seems capable of anything.>> P>> >>
the by clause is needed so the mavg is per ticker.
prefix with query with
ungroup