Try this:

-- Get the unique list
Create view vwUniqueBudgets AS +
  SELECT DISTINCT Account,Budget +
  FROM sourceTable

-- Get the total
SELECT sum(Budget) FROM vwUniqueBudgets


"Atrix Wolfe" <[EMAIL PROTECTED]> wrote:

>sorry, i didnt phrase my question correctly. �If i have:
>
>Account Budget
>1 � � � � � � �30
>1 � � � � � � �30
>2 � � � � � � �40
>2 � � � � � � �40
>3 � � � � � � �20
>3 � � � � � � �20
>
>i want the sum of the distinct account budgets...IE: 30+40+20=90 so i want it to 
>display 90 as the result. �Is this doable?
>
> �----- Original Message -----
> �From: randyp
> �To: [EMAIL PROTECTED]
> �Sent: Thursday, October 10, 2002 12:26 PM
> �Subject: Re: newbie sql question
>
>
> �SELECT account, SUM(budget) from [tableName] group by account.
>
> �This will show you the sum of however many budget amounts for each distinct account.
>
> �Account � �Budget
> �1 � � � � � � � �$ 200
> �1 � � � � � � � � � �300
> �2 � � � � � � � � � �100
>
> �will result in:
> �1 � � � � � � � �$ 500
> �2 � � � � � � � � � �100
>
> �If you use SUM(budget)=s the total of $ 600 will be listed underneath the 
>individual budget subtotals.
>
> � � � � �Randy Peterson
> � �----- Original Message -----
> � �From: Atrix Wolfe
> � �To: [EMAIL PROTECTED]
> � �Sent: Thursday, October 10, 2002 2:39 PM
> � �Subject: newbie sql question
>
>
> � �i know this is more of an sql question (and a newbie one at that) than an rbase 
>question but im having a problem tryin to figure this out.
>
> � �I have a table with 2 columns...1 is Account and the other is Budget. �What i 
>need is a sum of Budget, but there are duplicate entries so i need it to sum Budget 
>where Account is distinct. �Anyone know how to do this?
>
> � �thanx for the help!
>


-- 
Albert Berry
Full Time Consultant to
PSD Solutions
350 West Hubbard, Suite 210
Chicago, IL 60610
312-828-9253 Ext. 32


__________________________________________________________________
The NEW Netscape 7.0 browser is now available. Upgrade now! 
http://channels.netscape.com/ns/browsers/download.jsp 

Get your own FREE, personal Netscape Mail account today at http://webmail.netscape.com/
================================================
TO SEE MESSAGE POSTING GUIDELINES:
Send a plain text email to [EMAIL PROTECTED]
In the message body, put just two words: INTRO rbase-l
================================================
TO UNSUBSCRIBE: send a plain text email to [EMAIL PROTECTED]
In the message body, put just two words: UNSUBSCRIBE rbase-l
================================================
TO SEARCH ARCHIVES:
http://www.mail-archive.com/rbase-l%40sonetmail.com/

Reply via email to