Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 How to get data from 2 tables in that way i need
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Starting Member

1 Posts

Posted - 04/23/2013 :  13:29:13  Show Profile  Reply with Quote
Hello proffesionals!

This what i got like 2 tables(1 is money income 2nd is money outcome) almost with same column names like

id name user_id catalogue sum date(timestamp)

This what i need:
i need get data from both tables, then count SUM(sum) from both as one, but this is a bit hard because 2nd table sum values should be negative then SUM is counted. Also each SUM value should be counted for each day where we have any income,outcome (or just one of these) something like GROUP BY CAST(`data`AS DATE). Any ideas? Thanks for replies! :)

Very Important crosS Applying yaK Herder

52326 Posts

Posted - 04/23/2013 :  13:43:08  Show Profile  Reply with Quote

select dateadd(dd,datediff(dd,0,[date]),0), SUM([sum]) AS Total
FROM table1
FROM table2
GROUP BY dateadd(dd,datediff(dd,0,[date]),0)

SQL Server MVP
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.02 seconds. Powered By: Snitz Forums 2000