title: sql subquery how to get the desired value
body: <pre><code>DECLARE @deposit TABLE(
    checks VARCHAR(MAX),
    deposit VARCHAR(MAX)
  )
  
  INSERT INTO @deposit
  SELECT CheckID
       , Total
  FROM
    DISCOUNT_DETAIL
    INNER JOIN CHECK_DETAIL
      ON DISCOUNT_DETAIL.CheckDetailID = CHECK_DETAIL.CheckDetailID
  WHERE
    DISCOUNT_DETAIL.DscntID = '98'
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/40otl.jpg" alt="temptable"></p>
  
  <pre><code>SELECT CASE WHEN CHECK_DETAIL.CheckID IN (SELECT checks
                                            FROM @deposit) 
  THEN CHECKS.Payment + (SELECT abs(deposit) FROM @deposit)
                    ELSE
    CHECKS.Payment
  FROM ....
  </code></pre>
  
  <p>I received an error : subquery return more than one row.</p>
  
  <p>How do I achieve if my check id match with the temp table check id then only add that deposit to payment.</p>
  
  <p>I am using SQL server 2005.</p>
  
  <p>Thanks</p>