Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
I have two united select statements that are showing errors on a particular day. Errors are calculated:Table 1 with 3 columns date, value 1 and value 2Table 2 with 3 columns date, value 1 and value 2
SELECT table1.date, Round(table1.[value 1]-table2.[value 1],2) AS [Diff]FROM table1 INNER JOIN table2 ON table1.date = table2.dateWHERE (((table1.date)>=#10/1/2006#) UNIONSELECT table1.date, Round(table1.[value 2]-table2.[value 2],2) AS [Diff]FROM table1 INNER JOIN table2 ON table1.date = table2.dateWHERE (((table1.date)>=#10/1/2006#)
But this statements returns two columns: 1 date, 2 diff. I want it to display 3 columns: 1 date, 2 diff, 3 which value (1 or 2).Is this possible at all?
khtan
In (Som, Ni, Yak)
17689 Posts
Posted - 2007-02-16 : 09:43:53
like this ?
SELECT table1.date, Round(table1.[value 1]-table2.[value 1],2) AS [Diff], 1 as ValueFROM table1 INNER JOIN table2 ON table1.date = table2.dateWHERE (((table1.date)>=#10/1/2006#) UNIONSELECT table1.date, Round(table1.[value 2]-table2.[value 2],2) AS [Diff], 2 as ValueFROM table1 INNER JOIN table2 ON table1.date = table2.dateWHERE (((table1.date)>=#10/1/2006#)