[thelist] Creating Reports: Where to put the logic?

Matthew Bernhardt bernhardt.7 at osu.edu
Wed Jun 21 11:44:14 CDT 2006


Hey Casey,
   Try something along these lines:

SELECT salesRep, Sum(salesAmount) AS salesTotal
 FROM sales
GROUP BY salesRep

What db are you using? SQL server? MySQL? Oracle?

Matt

On Wed, 21 Jun 2006 12:31:32 -0400, Casey Crookston  
<caseyc at IntelliSoftmn.com> wrote:

> Ok, I'm creating a report which totals up sales by sales reps.  To
> simplify, we've got a query that looks like this (not really but for my
> learning purposes this will do):
>
>
> SELECT salesRep, salesAmount FROM sales
>
>
> And returns this:
>
>
> Billy Bob           45.00
>
> Billy Bob           50.00
>
> Sally Jane         79.00
>
> Sally Jane         32.00
>
> Billy Bob             5.00
>
> Sally Jane         20.00
>
> Sally Jane         10.00
>
>
> I need the report to look like this:
>
>
> Billy Bob           100.00
>
> Sally Jane         141.00
>
>
> I would really prefer to do the logic in the query, if that's possible.
> I've been looking at the sum(column) function, but can't quit get it
> working.  Is it possible, and if so, what would the query look like?
>
>
> Thanks!
>
>
> Casey
>



-- 
Matt Bernhardt, bernhardt.7 at osu.edu
Webmaster  +  Fab  Lab  Coordinator
Knowlton  School   of  Architecture
The    Ohio     State    University



More information about the thelist mailing list