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 |
hobartit
Starting Member
2 Posts |
Posted - 2010-12-13 : 12:14:35
|
I am a new comer to SQL and i am looking for the correct syntax to be able to subtract rows from 2 different tables. I have 2 tables both which include 2 columns. 1 called ticker and the other amount. I need to be able to subtract the amounts where the ticker in table 1= ticker in table 2.Table 1ticker, amountADN.L, 26000.00 AFE.L, 750000.00 EDIN.L, 25000.00EGU.L, 3553.00 Table 2ticker, amountADN.L, 46000.00AFE.L,850000.00EDIN.L,35000.00EGU.L,4553.00 I hope this makes sense, if you need further clarification please let me know. Any help much appreciated. |
|
russell
Pyro-ma-ni-yak
5072 Posts |
Posted - 2010-12-13 : 13:05:55
|
[code]SELECT t2.ticker, t2.amount - t1.amount as diffFROM Table1 t1JOIN Table2 t2On t1.ticker = t2.ticker[/code] |
|
|
hobartit
Starting Member
2 Posts |
Posted - 2010-12-14 : 03:34:22
|
RussellA maassive thanks for your help with this. Really appreciate it. If anyone has any recommendations on any good websites for learning SQL. Would really like to get to grips with itRegards |
|
|
|
|
|