I have three tables in a relational database: User, Expense, and ExpenseDescription.
User Table Fields: UserID, Name, Age
Expense Table Fields: ExpenseID, Amount, ExpenseDescriptionID, UserID
ExpenseDescription Fields: ExpenseDescriptionID, Description
Problem: I need to write a summary query that would return the following Columns:
User.Name, [sum of Expense.Amount for each type of expense] as ExpenseDescription.Description
This is where [sum of Amount for each type of expense] would create a column for every entry in the ExpenseDescription table. I have no idea where to begin on this. Does anyone know how I should go about this? Please let me know if I need to clarify this problem.
Here is a sample of the desired output if ExpenseDescription only had 3 columns:
Name RentalCar Hotel Misc
Joe 0 200 10
Bob 100 130 0
User Table Fields: UserID, Name, Age
Expense Table Fields: ExpenseID, Amount, ExpenseDescriptionID, UserID
ExpenseDescription Fields: ExpenseDescriptionID, Description
Problem: I need to write a summary query that would return the following Columns:
User.Name, [sum of Expense.Amount for each type of expense] as ExpenseDescription.Description
This is where [sum of Amount for each type of expense] would create a column for every entry in the ExpenseDescription table. I have no idea where to begin on this. Does anyone know how I should go about this? Please let me know if I need to clarify this problem.
Here is a sample of the desired output if ExpenseDescription only had 3 columns:
Name RentalCar Hotel Misc
Joe 0 200 10
Bob 100 130 0