OK, with the help of biziclops hint I found the CASE syntax and now got a solution:
SELECT wt.begin, wt.end, CASE
WHEN strftime('%w', wt.begin)='1' THEN Mon
WHEN strftime('%w', wt.begin)='2' THEN Tue
WHEN strftime('%w', wt.begin)='3' THEN Wed
WHEN strftime('%w', wt.begin)='4' THEN Thu
WHEN strftime('%w', wt.begin)='5' THEN Fri
WHEN strftime('%w', wt.begin)='6' THEN Sat
WHEN strftime('%w', wt.begin)='0' THEN Sun END
AS daybudget
FROM Week_Budget AS wb, Work_Times AS wt
WHERE t.begin BETWEEN wb.from AND wb.to;
I got two further questions:
- Is there a smarter way to do this?
- What is the better way to get this done? The solution above or a query with an INNER JOIN like the following:
Version 2:
SELECT wt.begin, wt.end, CASE
WHEN strftime('%w', wt.begin)='1' THEN Mon
WHEN strftime('%w', wt.begin)='2' THEN Tue
WHEN strftime('%w', wt.begin)='3' THEN Wed
WHEN strftime('%w', wt.begin)='4' THEN Thu
WHEN strftime('%w', wt.begin)='5' THEN Fri
WHEN strftime('%w', wt.begin)='6' THEN Sat
WHEN strftime('%w', wt.begin)='0' THEN Sun END
AS daybudget
FROM Week_Budget AS wb
INNER JOIN Work_Times AS wt
ON t.begin BETWEEN wb.from AND wb.to;