Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Getting error : #1242 - Subquery returns more than 1 row

Posted on 2011-02-14
3
543 Views
Last Modified: 2013-12-13
What should I do to correct this query.
SELECT `Index` , `FundName` ,Count(*), (SELECT COALESCE(sum(b.PricePerWeek),0)       
FROM tbl_FundSubscriptions      
WHERE DATE_SUB(CURDATE(),INTERVAL 7 DAY) <= SubscribeDt        GROUP BY FundIDSend)  
FROM tbl_FundSubscriptions b, tbl_FundStatic a  
WHERE a.FundID = b.FundIDSend  AND FundIDSend IN      (SELECT FundID      FROM tbl_FundStatic      WHERE UserID = '14')  
GROUP BY a.FundName,a.Index

Open in new window

0
Comment
Question by:meetpd
3 Comments
 
LVL 11

Expert Comment

by:David Kroll
ID: 34887940
This part of your query:

(SELECT COALESCE(sum(b.PricePerWeek),0)      
FROM tbl_FundSubscriptions      
WHERE DATE_SUB(CURDATE(),INTERVAL 7 DAY) <= SubscribeDt        GROUP BY FundIDSend)

can only return 1 row.  Maybe try using SELECT DISTINCT or SELECT TOP 1.
0
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 34888193
GROUP BY GROUP BY FundIDSend in that subquery shall be replaced by
 AND FundSubscriptions.FundIDSend = b.FundIDSend
0
 
LVL 32

Expert Comment

by:awking00
ID: 34890119
Can you provide some sample data for the FundSubscriptions and FundStatic tables and the single row you want to be returned?
0

Featured Post

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating and Managing Databases with phpMyAdmin in cPanel.
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
This video explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.
The viewer will learn how to count occurrences of each item in an array.

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question