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
 General SQL Server Forums
 New to SQL Server Programming
 Cross Tab help

Author  Topic 

werhardt
Constraint Violating Yak Guru

270 Posts

Posted - 2008-08-05 : 09:41:50
I have two tables I would like to check. The one table is called dhs_MonthEndProvidersREVISED and it has 510 records. The other table is called vw_MonthEndHospitalFullTable and there is 663 records. How do I find the ones that are not on the dhs_MonthEndProvidersREVISED table?

Would my statement look like this….
Select*
From dhs_MonthEndProvidersREVISED
Right join vw_MonthEndHospitalFullTable on [Hospital ID] <> [DoctorID]

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2008-08-05 : 09:51:22
why are you joining Hopital ID with DoctorID ?


Select *
From vw_MonthEndHospitalFullTable a
LEFT JOIN dhs_MonthEndProvidersREVISED b
ON a.[Hospital ID] = b.[Hospital ID]
WHERE b.[Hospital ID] IS NULL



KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

werhardt
Constraint Violating Yak Guru

270 Posts

Posted - 2008-08-05 : 09:54:23

Hospital ID and DoctorID means the same thing. The person who created the table just named them that way.

They me try this and see. Thanks.


quote:
Originally posted by khtan

why are you joining Hopital ID with DoctorID ?


Select *
From vw_MonthEndHospitalFullTable a
LEFT JOIN dhs_MonthEndProvidersREVISED b
ON a.[Hospital ID] = b.[Hospital ID]
WHERE b.[Hospital ID] IS NULL



KH
[spoiler]Time is always against us[/spoiler]



Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2008-08-05 : 09:57:38
quote:
Originally posted by werhardt


Hospital ID and DoctorID means the same thing. The person who created the table just named them that way.



This is ridicules. How in the world would anybody know that HospitalID is same as DoctorID ?


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

werhardt
Constraint Violating Yak Guru

270 Posts

Posted - 2008-08-05 : 10:11:24
welcome to my world!

quote:
Originally posted by khtan

quote:
Originally posted by werhardt


Hospital ID and DoctorID means the same thing. The person who created the table just named them that way.



This is ridicules. How in the world would anybody know that HospitalID is same as DoctorID ?


KH
[spoiler]Time is always against us[/spoiler]



Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-08-05 : 12:59:28
quote:
Originally posted by werhardt

welcome to my world!

quote:
Originally posted by khtan

quote:
Originally posted by werhardt


Hospital ID and DoctorID means the same thing. The person who created the table just named them that way.



This is ridicules. How in the world would anybody know that HospitalID is same as DoctorID ?


KH
[spoiler]Time is always against us[/spoiler]






it certainly is an example of bad naming.If ever somebody else have to work in this field there's no chance of them understanding what that field means other than somebody like you telling them if you happen to still work in this company or if there's some documentation available. so its always better to have field names corresponding what values actually represent.
Go to Top of Page
   

- Advertisement -