Closed. This question needs details or clarity . It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post .
Closed 3 days ago.
Improve this question
See script below:
select distinct
p.person_nbr as 'Person Number'
, case when month(getdate()) > month(date_of_birth) or month(getdate()) = month(date_of_birth) and day(getdate()) >= day(date_of_birth)
then datediff(year, date_of_birth, getdate())
else datediff(year, date_of_birth, getdate()) - 1
end as 'Age'
, primarycare_prov_name as 'Primary Care Provider'
, convert(varchar(20),cast (datetime as datetime),101) as 'Encounter Date'
, encounter_id as 'Encounter ID'
, rendering_provider as 'Rendering Provider'
, primary_insurance_name as 'Payor'
from
EDH_PHE_encounter epe (nolock)
join
person p (nolock)
on epe.person_nbr = p.person_nbr;
When I ran the commands for each table separately would produce hundreds of rows. After search for answers.
1条答案
按热度按时间pinkon5k1#
What kind of JOIN are you trying to perform?
I do believe that when you do not specify the type of join it is "INNER JOIN" by default. So, try with a LEFT JOIN for example:
There are three reasons why a query returns zero rows:
Since you stated none of those two tables are empty, and you do not have any WHERE condition active, the only thing that comes into my mind is that the join fields do not match, therefore acting as an inner join the interception is the null subset. You might want to make sure that there is actually a match between epe.person_nbr and p.person_nbr. This check is easy to perform, simply left join the distinct key fields of one and the other, and see if they match.
Hope this was somehow helpful.