Subject | thanks for the responses |
---|---|
Author | bwc3068 |
Post date | 2013-01-27T21:17:46Z |
thanks. it's not as simple as I was thinking (hoping?).
i'll give this a try
and you're correct with:
cheers
kelly
i'll give this a try
and you're correct with:
> This will at least almost give you what you specified as desired output in your first email, though ID 22 will be at the bottom since the record of ID 22 with the latest date is HHH and not AAA.that is the output i want. i incorrectly wrote the output in my question.
cheers
kelly
--- In firebird-support@yahoogroups.com, Svein Erling Tysvær wrote:
>
> >i might be phrasing it weird but
> >order by tag ( where date is most recent)
> >group by ID
> >
> phrased another way:
> >i want the IDs together or grouped
> >
> >i want the IDs sorted by the Tag of the most recent one.
>
> You're not phrasing it weird, Kelly, it is a slightly weird requirement! But here goes (it won't work on Firebird 1.5)
>
> with MyCTE as
> (SELECT ID, Tag
> FROM KellyTbl K1
> WHERE NOT EXISTS(SELECT * FROM KellyTbl K2
> WHERE K1.ID = K2.ID
> AND K1.Date < K2.Date))
> SELECT KT.Tag, KT.ID, KT.Date
> FROM KellyTbl KT
> JOIN MyCTE M ON M.ID = KT.ID
> ORDER BY M.Tag, KT.Date
>
> This will at least almost give you what you specified as desired output in your first email, though ID 22 will be at the bottom since the record of ID 22 with the latest date is HHH and not AAA.
>
> HTH,
> Set
>