473,471 Members | 1,748 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

I have a list- null, 1,2,3 and am asking for only the 1 but keep getting 1 and null.

3 New Member
In a subquery I only want the line 1 from a list of null, 1,2 and 3, but I keep getting line 1 and null. How can I get only line 1?
Expand|Select|Wrap|Line Numbers
  1.   (select HOSPICE_DX.PAT_ENC_CSN_ID
  2.            , edg.DX_NAME
  3.            , HOSPICE_DX.LINE
  4.             from HOSPICE_DX
  5.            inner join EDG on    HOSPICE_DX.HOSPICE_DX_CODED_ID=edg.DX_ID
  6.  
  7.            ) hospice on PAT_ENC.PAT_ENC_CSN_ID=hospice.PAT_ENC_CSN_ID and hospice.LINE=1  
thanks!
Jul 26 '13 #1
3 1562
Rabbit
12,516 Recognized Expert Moderator MVP
We need to see the rest of the SQL.
Jul 26 '13 #2
snelson476
3 New Member
Expand|Select|Wrap|Line Numbers
  1. select PATIENT.PAT_MRN_ID as MRN
  2. , PATIENT.PAT_NAME as Patient
  3. , convert(date,HH_EPSD_EVNT_DATES.DATE_OF_EVENT,101) as SOC
  4. , CASE when ZC_ACCT_CLASS_HA.NAME='Home Health' then diagnosis.DX_NAME else hospice.DX_NAME end as 'PRIMARY DX'
  5. , ZC_TEAM_ASSIGNMENT.NAME as TEAM
  6. , ZC_ACCT_CLASS_HA.NAME AS PROGRAM
  7. , hospice.LINE
  8.  
  9.  
  10.  
  11. from HSP_ACCOUNT
  12. inner join ZC_ACCT_CLASS_HA on HSP_ACCOUNT.ACCT_CLASS_HA_C=ZC_ACCT_CLASS_HA.ACCT_CLASS_HA_C
  13. inner join HSP_ACCOUNT_3 on HSP_ACCOUNT.HSP_ACCOUNT_ID=HSP_ACCOUNT_3.HSP_ACCOUNT_ID
  14. inner join HSP_TRANSACTIONS on HSP_ACCOUNT.HSP_ACCOUNT_ID=HSP_TRANSACTIONS.HSP_ACCOUNT_ID
  15. inner join PATIENT on HSP_ACCOUNT.PAT_ID=PATIENT.PAT_ID
  16. inner join PAT_ENC on HSP_ACCOUNT.HSP_ACCOUNT_ID=PAT_ENC.HSP_ACCOUNT_ID
  17. inner join EPISODE on HSP_ACCOUNT_3.HH_HSB_ID=EPISODE.EPISODE_ID
  18. inner join HH_EPSD_INFO on EPISODE.EPISODE_ID=HH_EPSD_INFO.SUMMARY_BLOCK_ID
  19. left join ZC_TEAM_ASSIGNMENT on HH_EPSD_INFO.TEAM_ASSIGNMENT_C=ZC_TEAM_ASSIGNMENT.TEAM_ASSIGNMENT_C
  20. inner join HH_EPSD_EVNT_DATES on HH_EPSD_INFO.SUMMARY_BLOCK_ID=HH_EPSD_EVNT_DATES.SUMMARY_BLOCK_ID
  21. inner join ZC_DATE_EVENT on HH_EPSD_EVNT_DATES.DATE_EVENT_C=ZC_DATE_EVENT.DATE_EVENT_C
  22. inner join HH_EPSD_EVNT_DATES as ed on HH_EPSD_INFO.SUMMARY_BLOCK_ID=ed.SUMMARY_BLOCK_ID
  23. inner join ZC_MC_PAT_STATUS on HH_EPSD_INFO.HC_DC_DISPOSITION_C=ZC_MC_PAT_STATUS.PAT_STATUS_C
  24. inner join CLARITY_DEP on HSP_TRANSACTIONS.DEPARTMENT=CLARITY_DEP.DEPARTMENT_ID
  25. left join (select HH_PAT_ENC.PAT_ID
  26.             , ROW_NUMBER() over(partition by hh_pat_enc.pat_id order by hh_pat_enc.prim_dx_start_date desc)enc_rank
  27.             , CLARITY_EDG.DX_NAME
  28.              from HH_PAT_ENC
  29.               inner join CLARITY_EDG on HH_PAT_ENC.PRIMARY_DX_ID=CLARITY_EDG.DX_ID
  30.                ) diagnosis on PATIENT.PAT_ID=diagnosis.PAT_ID and diagnosis.enc_rank='1'
  31. left join (select HOSPICE_DX.PAT_ENC_CSN_ID
  32.            , HOSPICE_DX.CONTACT_DATE
  33.            , edg.DX_NAME
  34.            , HOSPICE_DX.LINE
  35.             from HOSPICE_DX
  36.            inner join CLARITY_EDG as edg on HOSPICE_DX.HOSPICE_DX_CODED_ID=edg.DX_ID
  37.  
  38.            ) hospice on PAT_ENC.PAT_ENC_CSN_ID=hospice.PAT_ENC_CSN_ID and hospice.LINE=1 
  39.  
  40.  
  41. where ZC_DATE_EVENT.NAME in ('Start of Care Date (M0030,CMS 485.2)', 'Hospice Admission')
  42. and ZC_MC_PAT_STATUS.NAME <>  'Left Against Medical Advice or Discontinued Care'
  43. and EPISODE.STATUS_C<>'3'
  44.  
  45.  
  46.  
  47.  
  48.  
  49. group by EPISODE.EPISODE_ID
  50. , PATIENT.PAT_MRN_ID 
  51. , PATIENT.PAT_NAME
  52. , HH_EPSD_EVNT_DATES.DATE_OF_EVENT
  53. , ZC_TEAM_ASSIGNMENT.NAME 
  54. , ZC_ACCT_CLASS_HA.NAME
  55. , hospice.DX_NAME 
  56. , hospice.LINE
  57. , diagnosis.DX_NAME 
  58.  
  59.  
  60. order by 1 
Jul 26 '13 #3
Rabbit
12,516 Recognized Expert Moderator MVP
It's because you did a left join. A left join returns any rows in the left table that match the right table in addition to any rows in the left table that don't match any rows in the right table.
Jul 26 '13 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Vernon | last post by:
Hi anyone, This is my code. int num num = 0; for(int a=0; a<count; ++a){ if(current->transID==aNo) ++num; current = current->next;
4
by: Chefry | last post by:
I'm trying to set up an off the shelf script and keep getting an error. My host set up the mysql on my site and I changed the variables I had to in the settings.php file but I keep getting the...
2
by: iainw | last post by:
HI All, 1st post here, i wonder if you can help. We are about to upload CMS t a windows server and keep getting 2 errors below. We need to go LIVE an it's delaying us. An error occured when...
1
by: George W. | last post by:
Okay, I'm a C#/XML newbie, and I've been wrestling with this for a while now, checked dotnet sites, articles, MSDN Library, etc. and haven't been able to determine why this is happening. I have...
2
by: nfr | last post by:
I keep getting the following warning in my compile: Warning: The dependency 'WBWebServices, Version=1.0.1289.13943, Culture=neutral' in project 'WBWin' cannot be copied to the run directory...
2
by: partybob99 | last post by:
I am trying to call SP_Password from some vb.net code. This should be very straight forward but no matter what I do, I keep getting errors. Here is the code strConnectString = "Data Source=" +...
8
by: lawrence k | last post by:
I've installed Apache 1.3.36 on my Redhat EL 3 machine. Now I'm trying to install PHP 5.1.4. I can not get the ./configure command to work. I keep getting this error: configure: error: Invalid...
16
by: sangram | last post by:
how to delete last node of a Linked list if you only know the address of last node. thanks sangram
4
by: Daniel | last post by:
is there some per-process-limit on memory in .net processes? is there any way to increase it? i keep getting System.OutOfMemoryException when my box has 8 gigs of unused memory.
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.