Quantcast
Channel: SQL Server Database Engine forum
Viewing all articles
Browse latest Browse all 12963

SQL Query issue

$
0
0

HI - I have one peculiar issue with sql query.   Below query is not returning any rows.  The issue lies with store_code(st.store_code = 'MAUR') filter

select st.store_code, s.source_title,c.*from rpt.Combined c
join dim.store st 
on c.store_key = st.store_key  
join dim.source s
on c.source_key = s.source_key
where c.event_date_key = 20140406
and source_title = 'ADROIT'
and  st.store_code = 'MAUR'

However, if i use LTRIM(st.store_code)= 'MAUR' in the above query its returning the desired results.  I dont have any leading and trialing spaces for st.store_code in dim.store table.  To prove that i have executed the below query which is returning the results

select * from dim.store st where
 st.store_code = 'MAUR'

Can someone help in identifying the root cause for this issue.

thanks


Viewing all articles
Browse latest Browse all 12963

Trending Articles