Tuesday 15 February 2011

sql server - SUM Function For 2 Tables Produces Wrong Value -


Using: SQL Server 2008 R2

To calculate one percent of the total, Then there is a problem when running a total query (SUM) on two different tables individually, it produces the right amount; When the query is included in both, it comes with a huge value, so I did not know where it came from. Code, plus code that I'm running to create another table.

  Make a selection from the top 100 field table in the table SUM (t1.Field), TableOne T1 from SUM (t2.Field), TableTwo T2   

Tablet two has been obtained from ten percent of TableOne (which you can see in the first part of the query above). Note that personally, they produce the correct value:

  from the SELECT SUM (t1.Field) table a t1 SELECT SUM (t2.Field) table with two T2   

Is SQL Server the top query above, or am I clarifying something here?

  to Tableon T1, tablet to T2   < P> is a cross join. TED will be linked to  every  record  every one  record, which passes the required records to 10x (if T1 has 10% of T2 records).   

No comments:

Post a Comment