I am trying to get a table out of three different tables. I managed to count the paid field but cant get the correct values for Fee.
The Customer Table
╔════╦═════════════╗
║ ID ║ NAME ║
╠════╬═════════════╣
║ 1 ║ John Smith ║
║ 2 ║ Jim Jimmers ║
╚════╩═════════════╝
The Event table
╔════╦═════════════╦═════════════╦═════════════╗
║ ID ║ Event ║ Decription ║ Fee ║
╠════╬═════════════╬═════════════╬═════════════╣
║ 1 ║ Rock Music ║ Interseting ║ 80 ║
║ 2 ║ Pop music ║ Interseting ║ 90 ║
╚════╩═════════════╩═════════════╩═════════════╝
The Payment table
╔════╦═════════════╦═════════════╦═════════════╗
║ ID ║already Paid ║ Customer_ID ║ Event_ID ║
╠════╬═════════════╬═════════════╬═════════════╣
║ 1 ║ 0 ║ 1 ║ 1 ║
║ 2 ║ 90 ║ 1 ║ 2 ║
║ ║ ║ ║ ║
║ 3 ║ 90 ║ 2 ║ 2 ║
║ 4 ║ 80 ║ 2 ║ 1 ║
╚════╩═════════════╩═════════════╩═════════════╝
i am trying to get this table paid refers to what he already paid and fee refers to the events´ that he has to pay
╔═══════╦══════════╦═══════╗
║Name ║ paid ║ Fee ║
╠═══════╬══════════╬═══════╣
║John Sm║ 90 ║ 170 ║
║Jim Jim║ 170 ║ 170 ║
║ ║ ║ ║
║ ║ ║ ║
║ ║ ║ ║
║ ║ ║ ║
╚═══════╩══════════╩═══════╝