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.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Different results was produced

Author  Topic 

Vivahavana
Starting Member

1 Post

Posted - 2005-09-17 : 05:48:27
SELECT Table2.district_name, Table1.num_percent, Table1.num_ratio
FROM Table1 RIGHT OUTER JOIN
Table2 ON Table1.district_code = Table2.district_code
WHERE (Table2.state_code = 'CALIFORNIA')


Result on server1
DISTRICT1 0 0/0
DISTRICT2 0 0/3
DISTRICT3 0 0/0
DISTRICT4 0 0/0
DISTRICT5 0 0/2
DISTRICT6 0 0/0
DISTRICT7 0 0/0
DISTRICT8 0 0/0
DISTRICT9 0 0/0
DISTRICT10 0 0/0


Result on server2
DISTRICT1 NULL NULL
DISTRICT2 0 0/3
DISTRICT3 NULL NULL
DISTRICT4 NULL NULL
DISTRICT5 0 0/2
DISTRICT6 NULL NULL
DISTRICT7 NULL NULL
DISTRICT8 NULL NULL
DISTRICT9 NULL NULL
DISTRICT10 NULL NULL


The correct result is in Server2 but I dont know how in Server1 the num_percent and num_ratio value become zero when they suppose to be NULL.

Table1 only have 2 records, i.e
DISTRICT2 0 0/3
DISTRICT5 0 0/2
and when I use OUTER JOIN with Table2, it suppose to produce NULL value to num_percent and num_ratio whenever there is no matching district in Table2.

But for unknown reason, executing the SQL Server1 produce me with zero value to num_percent and num_ratio.

SamC
White Water Yakist

3467 Posts

Posted - 2005-09-17 : 09:20:48
It would be helpful if you would list sample data from Table2
Go to Top of Page

derrickleggett
Pointy Haired Yak DBA

4184 Posts

Posted - 2005-09-17 : 10:24:15
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

MeanOldDBA
derrickleggett@hotmail.com

When life gives you a lemon, fire the DBA.
Go to Top of Page
   

- Advertisement -