> Had some incorrect info in there.... Carry on  :-)
>
> Given the following journals with related documents.....
>
> Journal A
>
> document1a - Jan 1, 2004
> document2a - Jan 2, 2003
> document3a - Dec 3, 2002
>
> Journal B
>
> document1b - Jan 3, 2001
> document2b - Jan 4, 2000
> document3b - Dec 2, 1999
>
> Journal C
>
> document1c - Dec 3, 2002
> document2c - Jan 9, 2003
> document3c - Jan 9, 2004
>
> I would like to output to be like this....
>
> Journal C - Jan 9, 2004
> Journal A - Jan 1, 2004
> Journal B - Jan 3, 2001
>
> Anyone want to take a stab at it?
Try this:
SELECT j.title, MAX(d.createdate) AS maxdocdate
FROM journal j JOIN document d ON j.journalid = d.journalid
GROUP BY j.title
ORDER BY maxdocdate DESC

You can format your date output however you'd like.

HTH,
Stephen
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to