Hello,
I am working with a MS SQL Server 2005 database, I need to return the value of the last field in a group and I am having a problem getting it to work, the data comes from 2 different tables as follows:
StatusOptions.StatusNumber
StatusOptions.Description
StatusDetails.ID (incremented automatically)
StatusDetails.StatusNumber
StatusDetails.SalesOrderNumber
In the StatusDetails table a given sales order may have multiple entries such as received, in progress, shipped, etc. For a given sales order number I need to return the matching StatusOptions.Description field for the last entry in the StatusDetails.
For example the data may look like
StatusOptions.StatusNumber StatusOptionsDescription
1 Received
2 In-Progress
3 Shipped
StatusDetauls.ID StatusDetails.StatusNumber StatusDetails.SalesOrderNumber
1001 1 30005
1005 2 30005
1008 3 30005
I need the query to return Shipped.
I will greatly appreciate any feedback you can provide.
Mike
I am working with a MS SQL Server 2005 database, I need to return the value of the last field in a group and I am having a problem getting it to work, the data comes from 2 different tables as follows:
StatusOptions.StatusNumber
StatusOptions.Description
StatusDetails.ID (incremented automatically)
StatusDetails.StatusNumber
StatusDetails.SalesOrderNumber
In the StatusDetails table a given sales order may have multiple entries such as received, in progress, shipped, etc. For a given sales order number I need to return the matching StatusOptions.Description field for the last entry in the StatusDetails.
For example the data may look like
StatusOptions.StatusNumber StatusOptionsDescription
1 Received
2 In-Progress
3 Shipped
StatusDetauls.ID StatusDetails.StatusNumber StatusDetails.SalesOrderNumber
1001 1 30005
1005 2 30005
1008 3 30005
I need the query to return Shipped.
I will greatly appreciate any feedback you can provide.
Mike