try this...

Select SUM(SalesAmount) as SalesSum, EmpID
>From EmpSales
Where Quarter = 1
GROUP BY EmpID

you can use GROUP BY to group by that column.

+++++++++++++++++++++++++++++++++++++++++++++
Pete Freitag ([EMAIL PROTECTED])
CTO, CFDEV.COM
ColdFusion Developer Resources
http://www.cfdev.com/


-----Original Message-----
From: Dave Douglas [mailto:[EMAIL PROTECTED]]
Sent: Thursday, January 24, 2002 8:42 PM
To: CF-Talk
Subject: SUMMING Distinct Records


Hello,

I hae a table that has multiple records for the same EmpID with sales
amounts for each EmpID entry.
I am trying to SUM the SalesAmounts to create a quarterly report of total
sales by Employee.

<cfquery name="QuarterSales" datasource="EmpStats">
Select Distinct EmpID,
SalesAmount
>From EmpSales
Where Quarter = 1
</cfquery>

then I put it in cfgraph, as so:

<cfgraph type="bar" Title="Employee Quarterly Sales" Query="QuarterSales"
ValueColumn="SalesAmount" ItemColumn="EmpID" ColorList="blue,green">
</cfgraph>

Needless to say it shows Sales for each EmpID, repeating the same ID for as
many sales as their are.

I try this but to no avail:

<cfquery name="QuarterSales" datasource="EmpStats">
Select Distinct EmpID,
SUM(SalesAmount) as SalesSum
>From EmpSales
Where Quarter = 1
</cfquery>

Any Takers?

Thanks

______________________________________________________________________
Dedicated Windows 2000 Server
  PIII 800 / 256 MB RAM / 40 GB HD / 20 GB MO/XFER
  Instant Activation · $99/Month · Free Setup
  http://www.pennyhost.com/redirect.cfm?adcode=coldfusiona
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to