I have a basic table named customer:
CustId Name
AB1 George Arkin
AB2 Indiana James
AB3 Michael Anjelo
and another table named booking:
CustId FlightId Price
AB1 FL134 43.00
AB1 FL122 21.00
AB1 FL134 49.00
AB1 FL122 48.00
AB2 FL291 40.00
AB2 FL291 29.00
AB2 FL293 22.00
AB2 FL862 56.00
AB2 FL862 12.00
AB2 FL293 99.00
AB3 FL900 100.00
Now what I'd like to do is join both tables. I would then like to calculate how many flights a single person has booked (displaying all persons) and I would also like for each person the have a total price next to it adding up the total of each price they have paid. So far I came up with this:
SELECT C.CustId, C.Name, COUNT(DISTINCT B.FlightId) AS "NumberOfTicketsPurchased"
, SUM(DISTINCT B.Price) AS "TotalPrice"
FROM customer C, booking B
But I only get one result and the total price and count is not accurate.
P.S this is an example table for something I am practising in my own time to prepare for Data Management next Semester.