Solved

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

Posted on 2011-02-14
3
541 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 142

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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
This video shows how to recover a database from a user managed backup
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

911 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now