Advertisement

07.25.2008 at 02:13AM PDT, ID: 23594908
[x]
Attachment Details

nested sql select (urgent)

Asked by sinoj in SQL Query Syntax, Databases Miscellaneous, PostgreSQL Database

Tags: ERROR: more than one row returned by a subquery used as an expression

Hello experts,
  this may be a simple problem. My sql query return error. please help me fixing it. (I'm not good in SQL)

SQL error:
ERROR:  more than one row returned by a subquery used as an expression

Thank youStart Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
-- This query return error
 
select l.deposit_id,
sum(l.lot_value) as purchase_value,
sum((SELECT get_market_value_deposit(fal.asset_id, fal.deposit_id) FROM financial_asset_lot fal WHERE fal.deposit_id = l.deposit_id GROUP BY fal.asset_id, fal.deposit_id)) as market_value
FROM financial_asset_lot l
group by l.deposit_id
 
 
-- This one is working 
SELECT get_market_value_deposit(fal.asset_id, fal.deposit_id) FROM financial_asset_lot fal WHERE fal.deposit_id = 19 GROUP BY fal.asset_id, fal.deposit_id
 
output
----------
get_market_value_deposit
72801.05
50000
72408.31
85818.99
20729.68
71936.92
86476.57
133503.17
43175.7
77237.51
238832.6
55936.8
71138.29
203409.2
20033
58187.06
307230
38015.04
81832.74
86476.73
126617
---------------
[+][-]07.25.2008 at 02:29AM PDT, ID: 22087045

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.25.2008 at 02:38AM PDT, ID: 22087075

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]07.25.2008 at 02:41AM PDT, ID: 22087083

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.25.2008 at 02:46AM PDT, ID: 22087095

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.25.2008 at 02:47AM PDT, ID: 22087103

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.25.2008 at 02:49AM PDT, ID: 22087109

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.25.2008 at 02:51AM PDT, ID: 22087114

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.25.2008 at 02:53AM PDT, ID: 22087116

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.25.2008 at 02:53AM PDT, ID: 22087119

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: SQL Query Syntax, Databases Miscellaneous, PostgreSQL Database
Tags: ERROR: more than one row returned by a subquery used as an expression
Sign Up Now!
Solution Provided By: angelIII
Participating Experts: 2
Solution Grade: A
 
 
[+][-]07.25.2008 at 02:57AM PDT, ID: 22087131

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.25.2008 at 03:05AM PDT, ID: 22087158

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628