Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » DBISAM Technical Support » Support Forums » DBISAM SQL » View Thread |
Messages 1 to 3 of 3 total |
Last occurrence of a key |
Wed, Apr 4 2012 9:06 AM | Permanent Link |
Jose Eduardo Helminsky HPro Informatica | Table structure
EMP (Integer) DAT (Date) SEQ (Integer) Other fields Data sample: EMP DAT SEQ 1 2012-03-01 1 1 2012-03-01 2 1 2012-03-01 3 * 1 2012-03-02 1 1 2012-03-02 2 * 1 2012-03-03 1 * I would like to get the last occurrence of the last the key EMP + DAT + SEQ (the records with *) With the following SQL I get the keys but I need the "other fields". How can I do that ? select emp,dat,max(seq) from table group by emp,dat Eduardo |
Wed, Apr 4 2012 1:38 PM | Permanent Link |
John Hay | Eduardo
> Table structure > > EMP (Integer) > DAT (Date) > SEQ (Integer) > Other fields > > Data sample: > > EMP DAT SEQ > 1 2012-03-01 1 > 1 2012-03-01 2 > 1 2012-03-01 3 * > 1 2012-03-02 1 > 1 2012-03-02 2 * > 1 2012-03-03 1 * > > I would like to get the last occurrence of the last the key EMP + DAT + SEQ > (the records with *) One way would be to do it in 2 stages with a script eg select emp,dat,max(seq) as seq into memory\temp from table group by emp,dat; select emp,dat,seq,otherfields from memory\temp join table on temp.emp=table.emp and temp.dat=table.dat and temp.seq=table.seq John |
Thu, Apr 5 2012 5:56 AM | Permanent Link |
Jose Eduardo Helminsky HPro Informatica | John
Thanks for your tip. Eduardo |
This web page was last updated on Tuesday, April 30, 2024 at 03:55 PM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |