By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,527 Members | 1,256 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,527 IT Pros & Developers. It's quick & easy.

SubQuery with more than one row

Mahdis
P: 7
Hi,

i want to execute this Query :

Expand|Select|Wrap|Line Numbers
  1. SELECT Id_date
  2.      , Id_unit
  3.      , Id_code
  4.      , credit
  5.      , debt
  6.      , Balance
  7. FROM   tbl_Summery
  8.      , (select Balance
  9.         from tbl_Summery
  10.         where Id_date='02032012') as [MandGL]
  11. where  Id_date='02032012'
but i always received an error of: "Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression."
How can I solve this?

Thanks in Advanced
Nov 28 '12 #1
Share this Question
Share on Google+
2 Replies


NeoPa
Expert Mod 15k+
P: 31,768
A couple of points :
  1. [code] tags are not optional here. Please make sure you use them in any future posts.
  2. Laying out SQL as a simple string will not help you get answers. I've changed it so that it's more easily legible. Hopefully this will encourage more experts to look at your question.
  3. Summary is spelled with an 'A'. This won't effect your code at all, but I thought you may be interested anyway. English can be a hard language to use if not a native speaker, so helpful tips don't go amiss (I hope).
  4. I see nothing in your SQL that would make that error message make sense. The subquery isn't following any of those equality test characters.
  5. What I do see though, is that the field [Balance] is referred to ambiguously. Assuming you only want the one from the subquery try changing line #6 to
    Expand|Select|Wrap|Line Numbers
    1.      , MandGL.Balance
    and seeing if that helps any.

PS. Though I can't read your mind, I would suggest that it is very unlikely that your query will return anything sensible without some sort of JOIN between the two record sources. I'll leave that with you.
Nov 28 '12 #2

PsychoCoder
Expert Mod 100+
P: 465
My first question is why are you using a sub-query that's identical (in detail) to your original query? I cannot figure out what's being accomplished with that. Can you expand on that for me please? :)
Nov 29 '12 #3

Post your reply

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