List Info

Thread: Re: SQL PROBLEM




Re: SQL PROBLEM
country flaguser name
United States
2008-03-29 21:03:06

Tony,

Try this.

--select DISTINCT SUM(D_AMOUNT) ,D_TYPE
select SUM(D_AMOUNT) ,D_TYPE
FROM TYPE_DONATION, DONATIONS
WHERE TYPE_DONATION. DONATION_ ID IN (SELECT DISTINCT DONATION_ID FROM
DONATIONS WHERE MEMID = 4)
--GROUP BY D_AMOUNT, D_TYPE
GROUP BY D_TYPE

Good Luck!!

----- Original Message ----
From: tony_bat < tony_bat%40yahoo.com">tony_batyahoo.com>
To: delphi-en%40yahoogroups.com">delphi-enyahoogroups.com
Sent: Saturday, March 29, 2008 5:17:37 PM
Subject: [delphi-en] SQL PROBLEM

I am returning to many rows
In the following sql embedded sql will return three(3) rows.
so I get a sum for each row that is return
ex embedded sql returns x,y,z of course x,y,and z are really integers
sum 100 for x
sum 1oo for y
sum 100 for z
sum 200 for x
sum 200 for y
sum 200 for z
sum 300 for x
sum 300 for y
sum 300 for z
when all I want is
sum 100 for x
sum 200 for y
sum 300 for z

select DISTINCT SUM(D_AMOUNT) ,D_TYPE
FROM TYPE_DONATION, DONATIONS
WHERE TYPE_DONATION. DONATION_ ID IN (SELECT DISTINCT DONATION_ID FROM
DONATIONS WHERE MEMID = 4)
GROUP BY D_AMOUNT, D_TYPE

Thanks in advance for my over sight

Tony

__________________________________________________________
OMG, Sweet deal for Yahoo! users/friends:Get A Month of Blockbuster Total Access, No Cost. W00t
http://tc.deals.yahoo.com/tc/blockbuster/text2.com

[Non-text portions of this message have been removed]

__._,_.___
.

__,_._,___
Re: SQL PROBLEM
country flaguser name
United States
2008-03-30 02:04:57

why you are using 'D_AMOUNT' in GROUP BY clause:

Try the following:

select DISTINCT SUM(D_AMOUNT) ,D_TYPE
FROM TYPE_DONATION, DONATIONS
WHERE TYPE_DONATION. DONATION_ ID IN (SELECT DISTINCT DONATION_ID FROM
DONATIONS WHERE MEMID = 4)
GROUP BY D_TYPE

thanks

__._,_.___
.

__,_._,___
[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )