You are a true SQL guru, I should have brought it into 2 cursors to get the answer. Thanks again
Nick Patel
>I don't know how to create an sql statement for the following:
>
>
Vehicle Table
>VID
>VIN
>CAR TYPE
>
>
Service Table
>SID
>SERVICETYPE
>SERVICEDATE
>
>
>I have 2 table as show above. Vehicle table (one) has Cars that have automotive services performed and recorded in service table (many). Both tables are linked by VID and SID. I need to write a query that will show me when last certain type of service was perform for a vehicle: for example:
>
>
vehicle
>100 abc buick
>200 xyz ford
>
>
>
service
>100 oil 12/12/01
>200 tire 12/14/01
>100 oil 01/20/02
>100 oil 02/12/02
>200 tire 04/04/02
>
>
>I would like to know how to write a query that will pick the result for last service performed for example oil it should get
100 oil 02/12/02
or tire it should get
200 tire 04/04/02
. I know I can write a program to get the results, but I was wondering if there was a way to write SQL statement that can get the result?
>
>thanks
>nick patel