• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 562
  • Last Modified:

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

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
meetpd
Asked:
meetpd
1 Solution
 
David KrollCommented:
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
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
GROUP BY GROUP BY FundIDSend in that subquery shall be replaced by
 AND FundSubscriptions.FundIDSend = b.FundIDSend
0
 
awking00Commented:
Can you provide some sample data for the FundSubscriptions and FundStatic tables and the single row you want to be returned?
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now