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)
 get last record of a result set

Author  Topic 

henrikop
Constraint Violating Yak Guru

280 Posts

Posted - 2001-04-25 : 05:32:30
SQL 7.0

I have a table with records but three fields that matter.

Table Service moments

CustomerID Date ServiceCode
555 4/10/2001 10
555 4/14/2001 16
555 4/18/2001 19
555 4/20/2001 4

Somewhere else I need the ServiceCode but only if it exists in de ServiceCodeTable.

Table ServiceCodes
ServiceCode Category
10 600
16 650
30 680

What I want is the last ServiceCode from a customer (last as in date), which is in the table ServiceCodes.

In this example this would be (for customer 555) ServiceCode 16 at 4/10/2001.
becase 19 and 4 are not in my ServiceCode table. So ServiceCode 16 is the number I want to get.

ServiceCode 10 is also in the ServiceCode table, but in date ServiceCode 16 was the latest.

To give you some background information: I need to import information from the critical database into a management tool. In that tool I want to show the situation of a customer. Code 16 means service finished (which is relevant) while Code 19 means that the customer called with a (irrelevant) question.

Thx for looking at my problem!

Henri





   

- Advertisement -