SQL Query with SUM() |
03-01-2022, 04:54 AM
(This post was last modified: 03-03-2022, 09:35 AM by BFlokstra. Edit Reason: Formatting )
Hi guys,
Here is some background: I am building a claim system for our volunteers. Any time a volunteer uses their own car to get to a shift, they get €0,19 per kilometer to go towards gas. If they use public transport they get 100% of the fare reimbursed. What I'm trying to do now is get all claims for a specific volunteer, with a total of the payable price. Now, the volunteers can claim multiple shifts in one claim. To this end, I have set up two tables: claims: id int [PRIMARY, auto_inc] volunteer int, date date approved date payed date denied date iban varchar[18] account_holder TEXT claimrows: id int [PRIMARY, auto_inc] claim int shift int address TEXT kilometers int amount double(5,2) vehicle_type int payable double(5,2) (To make understanding the below easier, I translated the table, column and row names to english. I haven't changed anything else, so it's exactly how it's set up) I've written this query: Code: SELECT I'm now having two problems:
|
Welcome Guest, Not a member yet? Register Sign In |