Wrox Programmer Forums
|
SQL Language SQL Language discussions not specific to a particular RDBMS program or vendor.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Language section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 2nd, 2004, 03:35 AM
Authorized User
 
Join Date: Apr 2004
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default Sql-question

hello
I’ve got table A, B and AB that is a relational table of table A and B. In table AB I’ve got the following columns in:
IdAb
Date
FK_A
FK_B

I have several rows in table like this:

1, 2004, 1, 1
2, 2005, 1, 2
3, 2003, 2, 1

Now to my question;
How do I write my SQL-question to get the latest date for each FK_A like this:

2, 2005, 1, 2
3, 2003, 2, 1

Thanks in advance

Matte


 
Old July 2nd, 2004, 04:20 PM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 336
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to alyeng2000
Default

use order by 'Date Concatenation' [Asc|Desc]


Ahmed Ali
Software Developer
 
Old July 3rd, 2004, 06:39 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi Matte,

Use this.

Code:
SELECT max(DATECOLUMN), FK_A from AB group by FK_A
Cheers!

_________________________
- Vijay G
Strive for Perfection





Similar Threads
Thread Thread Starter Forum Replies Last Post
SQL Question psnow1985 ASP.NET 2.0 Basics 23 March 21st, 2008 11:48 AM
sql query question ldp101068 SQL Server 2000 6 December 3rd, 2007 03:41 PM
ASP / Sql question joebeem Classic ASP Basics 0 August 28th, 2007 02:45 PM
A SQL question pankaj_daga Access 5 December 5th, 2005 04:37 PM
SQL question U.N.C.L.E. SQL Server 2000 3 October 10th, 2003 02:00 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.