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.
Author |
Topic |
Trininole
Yak Posting Veteran
83 Posts |
Posted - 2013-09-27 : 14:26:37
|
I am writing a query now where I only want to get participants in the 112 service code only but this query I have is giving me other service codes as well when I have it set to 112. How can I fix this just so i can get this 112 service code only.declare @bgDte smalldatetimedeclare @enDte smalldatetimedeclare @rgn char(2)set @bgDte = '2013-01-01'set @enDte = '2013-04-30'set @rgn='05'select distinct sc.lname lastname,sc.fname firstname,sc.usn username,right(sc.ssn,4)Last4SSN,svp.servicecode,s.servicedescfrom ospr_workarea.dbo.static_claimants scjoinefmextract.dbo.serviceplan svpon sc.appid=svp.programappidjoinefmextract.dbo.services son svp.servicecode=s.servicecodejoin ospr_workarea.dbo.svpplx spon sc.appid=sp.appidwhere 1=1and svp.actualdate between @bgdte and @endteand svp.col_lwia=@rgnand svp.servicecode='112'Roger DeFour |
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2013-09-27 : 15:15:37
|
Does the servicecode column appear in ospr_workarea.dbo.static_claimants or ospr_workarea.dbo.svpplx? If so, then you've got "conflicting" data in those.Tara KizerSQL Server MVP since 2007http://weblogs.sqlteam.com/tarad/ |
|
|
Trininole
Yak Posting Veteran
83 Posts |
Posted - 2013-09-27 : 15:25:30
|
It is in the serviceplan table only.Roger DeFour |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2013-09-27 : 15:29:06
|
It's in services too according to the join. What is the data type of servicecode in both services and serviceplan? Though even a data type issue should not have this problem.Could you show us a data example?Tara KizerSQL Server MVP since 2007http://weblogs.sqlteam.com/tarad/ |
|
|
|
|
|