K query to fetch "last row for each ric" from a table.

Could anybody please help with the above queryEx:-Sample TableRic a b cL.T 1 2 3M.T 4 5 6L.T 1 4 6N.T 7 8 9N.T 9 1 2Sample OutputRic a b cL.T 1 4 6M.T 4 5 6N.T 9 1 2

Try using

select last Ric, a, b,c by Ric from SampleTable

the general form is “select from t where i=(last;i)fby Ric”

in this particular case, since you’re pulling the whole row, a shortcut form is “select by Ric from t”

btw, it’s easier to answer questions if you post your sample data in an executable format, e.g.

q)t:(Ric:L.TM.TL.TN.T`N.T;a:1 4 1 7 9;b:2 6 4 8 1;c:3 6 6 9 2)

this doesnt seem to be working.Could ou please explain it furtherhow does it return last row for each ric?On Feb 28, 6:10?pm, Aaron Davies <aaron.dav…> wrote:> the general form is “select from t where i=(last;i)fby Ric”>> in this particular case, since you’re pulling the whole row, a shortcut form is “select by Ric from t”>> btw, it’s easier to answer questions if you post your sample data in an executable format, e.g.>> q)t:(Ric:L.TM.TL.TN.T`N.T;a:1 4 1 7 9;b:2 6 4 8 1;c:3 6 6 9 2)>> On Feb 28, 2011, at 7:35 AM, akash wrote:>>>>>>>> > Could anybody please help with the above query>> > Ex:-> > Sample Table> > Ric ?a ?b ?c> > L.T ? 1 ?2 ?3> > M.T 4 ?5 ?6> > L.T ?1 ?4 ?6> > N.T ?7 ?8 ?9> > N.T ?9 1 ? 2>> > Sample Output>> > Ric ?a ?b ?c> > L.T ?1 ?4 ?6> > M.T ?4 ?5 ?6> > N.T ?9 ?1 ?2>> > –> >

Submitted via Google Groups</aaron.dav…>

this doesnt seem to be working.Could ou please explain it furtherhow does it return last row for each ric?On Feb 28, 6:10?pm, Aaron Davies <aaron.dav…> wrote:> the general form is “select from t where i=(last;i)fby Ric”>> in this particular case, since you’re pulling the whole row, a shortcut form is “select by Ric from t”>> btw, it’s easier to answer questions if you post your sample data in an executable format, e.g.>> q)t:(Ric:L.TM.TL.TN.T`N.T;a:1 4 1 7 9;b:2 6 4 8 1;c:3 6 6 9 2)>> On Feb 28, 2011, at 7:35 AM, akash wrote:>>>>>>>> > Could anybody please help with the above query>> > Ex:-> > Sample Table> > Ric ?a ?b ?c> > L.T ? 1 ?2 ?3> > M.T 4 ?5 ?6> > L.T ?1 ?4 ?6> > N.T ?7 ?8 ?9> > N.T ?9 1 ? 2>> > Sample Output>> > Ric ?a ?b ?c> > L.T ?1 ?4 ?6> > M.T ?4 ?5 ?6> > N.T ?9 ?1 ?2>> > –> >

Submitted via Google Groups</aaron.dav…>

please post a copy-and-paste of your session, along with what you expected the results to be