Rabu, 25 Januari 2012

[MS_AccessPros] Group by sum problem

 


I am using Access 2007 on a windows 7 system.

I have a query which gives me three records, one for BookingID=135
and two for BookingID=301. This is the SQL

SELECT PaymentsMT.Amount, PaymentsMT.BookingID
FROM PaymentsMT
WHERE (((PaymentsMT.Amount)>1) AND ((PaymentsMT.BookingID)=135 Or
(PaymentsMT.BookingID)=301));

I need to have a total per Booking ID and I have used this SQL:

SELECT Sum(PaymentsMT.Amount) AS SumOfAmount, PaymentsMT.BookingID
FROM PaymentsMT
GROUP BY PaymentsMT.BookingID
HAVING (((Sum(PaymentsMT.Amount))>1) AND ((PaymentsMT.BookingID)=135
Or (PaymentsMT.BookingID)=301));

which produces no records.

What have I missed?

Many thanks,

Robin Chapple

__._,_.___
.

__,_._,___

Tidak ada komentar:

Posting Komentar