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.
| Author |
Topic |
|
Bortiquai
Starting Member
4 Posts |
Posted - 2007-10-26 : 18:11:31
|
| I have 2 tables I need to pull data from. Basically, it is customer information and order information.In the customer Information (CustomerInfo), I've got the columns:CustomerID, FirstName, LastNameIn the Order Information (OrderInfo), I've got the columns:OrderID, BillToCustomerID, ShipToCustomerIDAs you can see, the billing and shipping information can be different. I need a SQL Statement that will display both, so the resultant dataset would look something like:OrderID, ShipFirst, ShipLast, BillFirst, BillLastI need the First and Last name from CustomerInfo where ShipToCustomerID = CustomerIDand in the same dataset, I need the First and Last Name from CustomerInfo where BillToCustomerID = CustomerID.I've tried my luck at a few statements, but can't seem to get it.Thanks |
|
|
Will H
Yak Posting Veteran
56 Posts |
Posted - 2007-10-26 : 18:27:09
|
| Something like this?SELECT o.OrderID, b.FirstName BillToFirst, b.LastName BillToLast, s.FirstName shipToFirst, s.LastName shipToLastFROM OrderInfo o JOIN CustomerInfo b on b.CustomerID = o.BillToID JOIN CustomerInfo s on s.CustomerID = o.ShipToID---------------------------------------------------------SSRS Kills Kittens. |
 |
|
|
|
|
|
|
|