thank you very much this helps.
i have another query.
OrderHistory table, has list of values for order.
I have to query for last row from the orderhistory table, get addressID, query address information from address table.
I was able to write the query.
I also has to get user who submitted the order from OrderHistory table.
Can i include this in the same query? if so, how to join the query?
OrderHistory table
OrderHistoryID
OrderID
AddressID
OrderStatusID
UserID
select top 1 addressID from OrderHistory where OrderID=1 order by OrderHistoryID
I want userid from OrderHistory where OrderStatusID=2.
can i combine both queries ?