Sum in database 
Author Message
 Sum in database

Hi!
  I need to sum a field in a table, I also need it to select only certain records.

Something like this:

SELECT * FROM dagsproduskjon WHERE vare_id = 1 ; <-- this can  be different.
SUM produksjon

Can I do this in SQL? I know that MS Access can do it.

Thanks?

--
Sten Karsten Vartdal

http://www.***.com/ ~stenvart/



Wed, 18 Jun 1902 08:00:00 GMT
 Sum in database

Hi Sten,

Look for aggregate functions in whatever SQL documentation. Example:

  SELECT id, COUNT(id), SUM(price * sold_count)
    FROM sales
    WHERE id > 500
    GROUP BY id;

HTH

Martin Schayna

Quote:

> Hi!
>   I need to sum a field in a table, I also need it to select only certain
records.

> Something like this:

> SELECT * FROM dagsproduskjon WHERE vare_id = 1 ; <-- this can  be
different.
> SUM produksjon

> Can I do this in SQL? I know that MS Access can do it.



Wed, 18 Jun 1902 08:00:00 GMT
 
 [ 2 post ] 

 Relevant Pages 

1. Adding and summing up database columns/rows

2. Sum(Sum(Sum ...

3. Which is faster Sum(fld1) + Sum(fld2) +...Sum(fld50) -- OR this

4. Performing a sum on a sum

5. Q: how to SUM the SUM?

6. sum of a sum

7. Getting a sum of a sum...

8. How to get the sum of Sums...

9. Sum Of SUM

10. SQL Plus -- need detail lines and sum of Amount, if the sum is not 0

11. Sum of a (views) sum

12. Summing non-summed break-on's


 
Powered by phpBB® Forum Software