help need with the most amount paid
I have a mysql database which has 3 tables.
tblCustomer details:
CustomerID
Name
Address
Suburb
State
Country
PostalCode
tblCourses details:
CourseID
CourseName
Location
StartDate
EndDate
Confirmed
CourseDescription
CourseFee
tblCourseRegistration details:
CRegistrationID
CustomerID
CourseID
CRegistrationDate
CRegistrationPaid
My code:
use myDatabase;
select distinct tblcustomer.name
(select sum(CRegistrationPaid) from tblcourseregistration
where tblcourseregistration.CustomerID = tblCustomer.CustomerID)
as 'TotalPaid'
from tblCourseRegistration, tblcourses, tblcustomer
where tblcourseregistration.CourseID=tblCourses.CourseID and
tblCustomer.CustomerID =tblCourseregistration.Customerid
order by totalpaid desc limit 1;
I need to be able to be able to display who has paid the most money
My code only displays 1 record, however I need it to display all of the customers who have paid the most money.
For example if 1 customers has paid the total amount of $500 it would display that 1 customer.
For example if 2 customers has paid the total amount of $500 it would display those 2 customers.
Subject
Written By
Posted
help need with the most amount paid
July 30, 2015 05:05PM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.