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 |
josef
Starting Member
15 Posts |
Posted - 2013-08-10 : 01:07:56
|
hello friendshelp me to write sql query that will filter between two dates (user input in text box1 and text box2) in the bellow sql statement .any bit of info would be helpfulSELECT 'Table1' AS [Table], SUM(a) - SUM(b) AS Result FROM table1 UNION ALL SELECT 'Table2', SUM(a) - SUM(b) FROM table2 UNION ALL SELECT 'Table3', SUM(a) - SUM(b) FROM table3 |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2013-08-10 : 03:05:20
|
[code]DECLARE @FromDate DATE = {Content from textbox 1}, @ToDate DATE = {Content from textbox 2};SELECT 'Table1' AS [Table], SUM(a) - SUM(b) AS Result FROM dbo.Table1WHERE MyDateTimeColumn BETWEEN @FromDate AND @ToDateUNION ALL SELECT 'Table2', SUM(a) - SUM(b) FROM dbo.Table2 WHERE MyDateTimeColumn BETWEEN @FromDate AND @ToDateUNION ALL SELECT 'Table3', SUM(a) - SUM(b) FROM dbo.Table3WHERE MyDateTimeColumn BETWEEN @FromDate AND @ToDate;[/code] Microsoft SQL Server MVP, MCT, MCSE, MCSA, MCP, MCITP, MCTS, MCDBA |
|
|
josef
Starting Member
15 Posts |
Posted - 2013-08-14 : 03:08:36
|
Thanks for your reply. I got the logic ,I can solve the problem . |
|
|
|
|
|
|
|