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 |
|
NuPath
Starting Member
4 Posts |
Posted - 2010-03-02 : 09:16:24
|
| Hello,I have two tables that have fields that contain dates and financial amounts. I have the following query that sums the financial data and groups them by month:SELECT DATENAME(mm, MyDateColumn) AS 'Month' , Sum(MyDollarColumn) AS SumAmount FROM Table1 GROUP BY DATENAME(mm, MyDateColumn) ORDER BY DATENAME(mm, MyDateColumn) This works fine however, I would like to include summed data from the other table as well. The other table has a date and financial column as well. Thanks for any help... |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-03-02 : 09:18:59
|
| [code]SELECT DATENAME(mm, MyDateColumn) AS 'Month' , Sum(MyDollarColumn) AS SumAmount FROM (SELECT MyDateColumn,MyDollarColumn FROM Table1 UNION ALL SELECT DateColumn,DollarColumn FROM OtherTable)t GROUP BY DATENAME(mm, MyDateColumn) ORDER BY DATENAME(mm, MyDateColumn) [/code]------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|