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 |
johnmitch38
Starting Member
9 Posts |
Posted - 2013-10-29 : 13:14:42
|
Hi all,I'm new to SQL so please tolerate my ignorance.I have a pretty simple SQL query that has two columns that contains only numbers. Is there a way i can add an extra column that simply subtracts the number in one column from number in the other column.I query the data tables rather than have a live link so the .csv file gets overwritten every time i run the query.Thanks,JM |
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
Posted - 2013-10-29 : 13:44:31
|
Here's one way:select col1, col2, col2-col1 as [difference] from yourTableBe One with the OptimizerTG |
|
|
johnmitch38
Starting Member
9 Posts |
Posted - 2013-10-30 : 04:50:55
|
Fantastic thanks.On a similar topic, can i add a command that will sum a whole column and place the total at the bottom of the column?JM |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2013-10-30 : 05:23:52
|
Look for WITH ROLLUP in SQL Server help fileMadhivananFailing to plan is Planning to fail |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-10-30 : 07:58:10
|
quote: Originally posted by johnmitch38 Fantastic thanks.On a similar topic, can i add a command that will sum a whole column and place the total at the bottom of the column?JM
seehttp://technet.microsoft.com/en-us/library/bb522495(v=sql.100).aspx------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
|
|
|