How to find the date and price that lowest close price occurs within

Hi, there,I have a table “stk_data” to contain the daily close price for all thestocks in the market .sym date close-------------------------SH600810 2012.05.17 8.01SH600810 2012.05.16 7.89SH600810 2012.05.15 8.1SH600810 2012.05.14 8.36SH600810 2012.05.11 8.35SH600810 2012.05.10 8.16SH600810 2012.05.09 8.12And I want to define a function"find_lowest[stk_data;start_date;end_date]" which output a table thattells the date and the price that lowest close price occurs within theperiod defined by the “start_date” and “end_date” . like this :sym date_occur close-------------------------SH600810 2012.04.03 6.89SH600732 2012.05.06 20.23SH600367 2012.04.25 12.50Can someone help to tell how to write the q code ?Thanks,Halley

select from stk_data where date within(start_date;end_date),close=(min;close)fby sym

I try “select from stk_data where datewithin(2012.05.16;2012.01.01),close=(min;close) fby sym”, but returntable is empty , just display the column name without any data !! (Icheck the “stk_data” did have data inside.). Why ?On 5??17??, ???10?58??, Fintan Quill <fin…> wrote:> select from stk_data where date> within(start_date;end_date),close=(min;close)fby sym>>>> On Wed, May 16, 2012 at 10:46 PM, bigbug <matlab…> wrote:> > Hi, there,>> > I have a table “stk_data” to contain the daily close price for all the> > stocks in the market .> > sym date close> > -------------------------> > SH600810 2012.05.17 8.01> > SH600810 2012.05.16 7.89> > SH600810 2012.05.15 8.1> > SH600810 2012.05.14 8.36> > SH600810 2012.05.11 8.35> > SH600810 2012.05.10 8.16> > SH600810 2012.05.09 8.12>> > And I want to define a function> > “find_lowest[stk_data;start_date;end_date]” which output a table that> > tells the date and the price that lowest close price occurs within the> > period defined by the “start_date” and “end_date” . like this :>> > sym date_occur close> > -------------------------> > SH600810 2012.04.03 6.89> > SH600732 2012.05.06 20.23> > SH600367 2012.04.25 12.50>> > Can someone help to tell how to write the q code ?>> > Thanks,> > Halley>> > –> >

Submitted via Google Groups</matlab…></fin…>

In your example start_date>end_date

Try:

select from stk_data where date within(2012.01.01;2012.05.16),close=(min;close) fby sym 

Amazing !! Thank you very much. I need to learn more to catch KDB+capability.On 5??17??, ???11?24??, Fintan Quill <fin…> wrote:> In your example start_date>end_date>> Try:> select from stk_data where> date within(2012.01.01;2012.05.16),close=(min;close) fby sym>>>> On Wed, May 16, 2012 at 11:20 PM, bigbug <matlab…> wrote:> > I try “select from stk_data where date> > within(2012.05.16;2012.01.01),close=(min;close) fby sym”, but return> > table is empty , just display the column name without any data !! (I> > check the “stk_data” did have data inside.). Why ?>> > On 5??17??, ???10?58??, Fintan Quill <fin…> wrote:> > > select from stk_data where date> > > within(start_date;end_date),close=(min;close)fby sym>> > > On Wed, May 16, 2012 at 10:46 PM, bigbug <matlab…> wrote:> > > > Hi, there,>> > > > I have a table “stk_data” to contain the daily close price for all the> > > > stocks in the market .> > > > sym date close> > > > -------------------------> > > > SH600810 2012.05.17 8.01> > > > SH600810 2012.05.16 7.89> > > > SH600810 2012.05.15 8.1> > > > SH600810 2012.05.14 8.36> > > > SH600810 2012.05.11 8.35> > > > SH600810 2012.05.10 8.16> > > > SH600810 2012.05.09 8.12>> > > > And I want to define a function> > > > “find_lowest[stk_data;start_date;end_date]” which output a table that> > > > tells the date and the price that lowest close price occurs within the> > > > period defined by the “start_date” and “end_date” . like this :>> > > > sym date_occur close> > > > -------------------------> > > > SH600810 2012.04.03 6.89> > > > SH600732 2012.05.06 20.23> > > > SH600367 2012.04.25 12.50>> > > > Can someone help to tell how to write the q code ?>> > > > Thanks,> > > > Halley>> > > > –> > > > You received this message because you are subscribed to the Google> > Groups> > > > “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+unsubscribe@googlegroups.com.> > > > For more options, visit this group at> > > >http://groups.google.com/group/personal-kdbplus?hl=en.-??? ->> > > - ???õ??? ->> > –> >

Submitted via Google Groups</matlab…></fin…></matlab…></fin…>

To: personal-kdbplus@googlegroups.comX-Mailer: Apple Mail (2.1084)>> select from stk_data where date within(2012.01.01;2012.05.16),close=(min;close) fby sym> > Amazing !! Thank you very much. I need to learn more to catch KDB+ capability.note that the list form (parens and semi-colon) are unnecessary with literalsselect from stk_data where date within 2012.01.01 2012.05.16,close=(min;close)fby sym

To: personal-kdbplus@googlegroups.comX-Mailer: Apple Mail (2.1257)not just unnecessary, but has performance penalty implicationsOn 18 May 2012, at 04:51, Aaron Davies wrote:>>> select from stk_data where date within(2012.01.01;2012.05.16),close=(min;close) fby sym>> >> Amazing !! Thank you very much. I need to learn more to catch KDB+ capability.> > note that the list form (parens and semi-colon) are unnecessary with literals> > select from stk_data where date within 2012.01.01 2012.05.16,close=(min;close)fby sym> > – > Submitted via Google Groups