Note that there are some explanatory texts on larger screens.

plurals
  1. POA SQL case statement or two
    primarykey
    data
    text
    <p>I have a <code>SELECT</code> statement that pulls these two different product strips. When I delete one of them from the website and rerun my statement I still have two rows, the first column has the <code>ARMCODE</code> twice (two results) and the second column has the description for the first but then no description for the second (because it has been deleted).</p> <p>Problem is it's still showing two results in SQL studio with the <code>ARMCODE</code>. </p> <p>If there is a <code>a.CODE_</code>,<code>a.strips</code> from intake it needs to show, if there is an <code>A.ARMCODE</code> and <code>B.DESCRIPTION</code> it needs to show. If there is only <code>A.ARMCODE</code> and <code>B.DESCRIPTION</code> and the other has been deleted why is it still showing two results with <code>a.CODE_</code> being the second result and an empty a.strips. </p> <pre><code>select a.ARMCODE, b.DESCRIPTION_ from ARE.AAS.REORDER a left outer join ARE.AAS.PTDME b on a.PTCODE=b.CODE_ where a.ARMCODE = 'ADSMANZS03' and b.MEDICAREID ='A4253' union all select a.CODE_,a.strips from event.dbo.intake a where a.CODE_ = 'ADSMANZS03' </code></pre> <p><img src="https://i.stack.imgur.com/2SNpo.jpg" alt="Strips and description, two different products, same patient"></p> <p><img src="https://i.stack.imgur.com/S5emW.jpg" alt="When i delete strips, still showing two results with empty description"></p> <p><img src="https://i.stack.imgur.com/sLxIC.jpg" alt="my case statement returning nothing"></p> <p>I started on a new statement using case and am now using some nested joins:</p> <pre><code>select case when b.ARMCODE is null then a.strips end from (select * from ev.dbo.intake a where a.CODE_ = 'ADSMANZS03') a left outer join(select a.ARMCODE, b.DESCRIPTION_ from ARE.AAS.REORDER a left outer join ARE.AAS.PTDME b on a.PTCODE=b.CODE_ where a.ARMCODE = 'ADSMANZS03' and b.MEDICAREID ='A4253') b on a.CODE_=b.ARMCODE </code></pre> <p>I'm not getting any rows or columns and it's returning (no column name) and inside NULL</p> <p>Hope that is not too confusing. Thanks in advance.</p> <p><strong>IMAGE 1</strong> Strips and description, two different products, same patient</p> <p><strong>IMAGE 2</strong> When i delete strips, still showing two results with empty description, should not show a second result.</p> <p><strong>IMAGE 3</strong> case statement</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload