[Sorry for the accidental premature sending in the first post...]

CREATE TABLE `payments` (
  `date` date NOT NULL,
  `payee` varchar(255),
  `amount` double
)

INSERT INTO payments VALUES ('2003-05-01','david',38);
INSERT INTO payments VALUES ('2003-06-02','david',13.4);
INSERT INTO payments VALUES ('2003-07-03','david',11.4);
INSERT INTO payments VALUES ('2003-08-04','david',5);
INSERT INTO payments VALUES ('2003-09-05','david',158.02);

INSERT INTO payments VALUES ('2003-05-09','lizzy',40.66);
INSERT INTO payments VALUES ('2003-06-08','lizzy',7.77);
INSERT INTO payments VALUES ('2003-07-07','lizzy',246);
INSERT INTO payments VALUES ('2003-08-06','lizzy',54);
INSERT INTO payments VALUES ('2003-09-10','lizzy',30);

The 'payments' table records the amount of money that should be paid to each person every month. But the actual cheque is only given when the total accumulated amount has reached $50 or more for that person. So for example, 'lizzy' receives cheques in July (in May she only has $40.66, and in June only $48.43 [40.66+7.77]) and August ($54). September payment is not actually paid yet to her, she will have to wait until October or November and so on until the amount has reached $50.

I want to list the amount of money that needs to be paid by cheques.

Can I do this with in pure SQL (instead of having to create logic in
programming language)?

Thanks in advance,

--
dave


-- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]



Reply via email to