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)
 Need to Select multiple highest values in tables

Author  Topic 

jimCrowe
Starting Member

2 Posts

Posted - 2008-10-03 : 06:31:07
Hi,

I'm having a few problems with a Select statement. Here the Scenario:

Table - Names

NameID Name
1 Jon
2 Andrew
3 Steve

Names.NameID has a 1 to many relationship with NameStatusTracking.NameID

Table - NameStatusTracking

NameStatusTrackingID NameID StatusID
1 1 1
2 1 2
3 2 1
4 4 3
5 1 3
6 3 1
7 2 2

I need to select 'Names.Name' and there highest NameStatusTracking.StatusID for each person in the names table.

E.g. I would like results to look like

Name StatusID
Jon 3
Andrew 2
Steve 1

I've tried selecting Names.Name and Joining NameStatusTracking.StatusID but I obviously get all the StatusID's whereas I only wantthe highest!

Manky thanks,

Jim

jimCrowe
Starting Member

2 Posts

Posted - 2008-10-03 : 06:56:52
Hi Guys,

All sorted I wasn't using the Group by clase on my aggregate functions
Go to Top of Page
   

- Advertisement -