Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Join tables help

Status
Not open for further replies.

croiva25

Technical User
Dec 3, 2003
125
AU
Could somebody please explain to me how do we join a table onto itself as that is what I was advised to do but I can't quite get where I want to go.

What I want to do is list values from a table,but those values can be just a quote (what would cost if they decided to go for that option) or those values can represent what was spent and invoiced, what is confusing me is that all of that gets saved in the same table and in same columns, so what was quoted for example for AirFares and what was spent gets saved in the same record but when it is "quoted amount" then ID = 1 but when it is invoiced ID = -1 and that is how we know what was quoted and what was invoiced.

But I need to split that one field into two columns one showing AirFareQuoted and one AirFareInvoiced and i have no idea how to achieve this.

I hope this makes sense and somebody can help me
 
Bit confused but this may help, if not can you give an example of a record and the result you expect.

Code:
select AirFareQuoted = CASE ID WHEN 1 THEN AirFares ELSE 0  END, 
       AirFareInvoiced  = CASE ID WHEN 1 THEN 0 ELSE AirFares  END 
FROM MyTable
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top