Query for golf score tracking db in Libre Base

16 views Asked by At

Here's where I need help; My sql skills only take me so far.

I want to assign a set of values to the "Hole 1 Delta" value based on the following criterion:

  • If Delta is = -2 (which is an eagle) I want to assign 6 points to a field called "Hole 1 Points"
  • If Delta is = -1 (which is a birdie) I want to assign 4 points to a field called "Hole 1 Points"
  • If Delta is = 0 (which is a par) I want to assign 2 points to a field called "Hole 1 Points"
  • If Delta is = +1 (which is a bogie) I want to assign 1 point to a field called "Hole 1 Points"
  • If Delta is >+1 zero points get assigned.

I have a lookup table with the values but my sql skills can't figure out how to utilize. Table is called Score_Lookup

I tried building a query but I can't figure out how to do nested IF to get my values. Here's my sql;

SELECT "Date", "Course Name", "Hole 1 Delta", "Hole 1 Delta" + 2 AS "Hole 1 Points"
FROM "Points_Calc"
WHERE "Hole 1 Delta" = 0
0

There are 0 answers