I have some values I'd like to sum up, but I want to skip any duplicate entries from the sum
For instance a table with 2 fields, Jobnumber & quantity. Would have data like this:
Jobnumber Quantity
1 10
1 10
2 25
2 25
3 1
4 2
4 2
4 2
How can I sum the quantity field and come up with a total of 38.
this is on a report so I cant do a no duplicates in the table.
It would be really nice if I could "Calculate sum(qty) for jobnumer is unique"
CREATE CURSOR byby (f1 i, f2 i)
INSERT INTO byby VALUES (1, 10)
INSERT INTO byby VALUES (1, 10)
INSERT INTO byby VALUES (2, 25)
INSERT INTO byby VALUES (2, 25)
INSERT INTO byby VALUES (3, 1)
INSERT INTO byby VALUES (4, 2)
INSERT INTO byby VALUES (4, 2)
INSERT INTO byby VALUES (4, 2)
SELECT f1, sum(distinct f2) sd FROM byby GROUP BY f1
SELECT sum(distinct f2) td FROM byby
Fabio