Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 max query

Author  Topic 

lane0618
Posting Yak Master

134 Posts

Posted - 2002-11-14 : 13:53:49
Here is a sample of the records:

directory filename
/usr5/released.Z/5022545_b_02.Z 5022545.prt.2
/usr5/released.Z/5022545_b_03.Z 5022545.prt.3
/usr5/released.Z/5023683_d_02.Z 5023683.prt.2
/usr5/released.Z/5023683_d_03.Z 5023683.prt.3
/usr5/released.Z/5023683_d_04.Z 5023683.prt.4

This doesn't work:
SELECT max(left(filename,7)), max(directory)
FROM proE_parts_only
WHERE (filename LIKE '50%')
and filename like '%.prt%'

Here is what I want, the highest revision of each filename and directory:
/usr5/released.Z/5022545_b_03.Z 5022545.prt.3
/usr5/released.Z/5023683_d_04.Z 5023683.prt.4

How can I make this work?

Thanks,
Lane

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2002-11-14 : 14:22:48
You want to GROUP BY filename (not MAX) and then get the MAX of directory.

Go to Top of Page
   

- Advertisement -