We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now


Subquery returned more than 1 value error

lcallah93 asked
Medium Priority
Last Modified: 2012-05-11
I am trying to add a column to my results that shows a conditional total but I keep getting the following error:

Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.

My query is below:

--Outstanding pledge balances

select g.giftid
            ,(select g.giftamount as BalanceDue from gifts_full where gifttype='p')
from gifts_full g left outer join payments_full p on g.giftkey=p.paylinkkey
          left outer join payments_VIEW_schedule_total_by_fy s on g.giftkey=s.paylinkkey
            left outer join names_VIEW_preferred n on g.giftid=n.nameid
            join chart_of_accounts c on g.giftrest=c.chart_code
            join division d on c.chart_div=d.table_code
            --left outer join (select g1.giftamount as g1.BalanceDue from gifts_full) g1 on g1.giftkey=p.paylinkkey
where g.gifttype in ('p', 'y', 'w') -- only include pledges and payments
            and g.giftjntkey<2 -- exclude joint recipients
            and g.gifttpledg>0

I am trying to show a balance due for any outstanding pledges - if the gift type is 'p' then giftamount as BalanceDue.

As always, any help is GREATLY appreciated!!

Watch Question

Senior .Net Consultant
Top Expert 2016
Unlock this solution and get a sample of our free trial.
(No credit card required)


Ahh..the CASE statement.  I am a newbie to SQL but have heard many good things about the CASE statement.  It gave me exactly what I needed - thank you!!
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.