[Solved] Maths or Logical Issue

Creating tables and queries
Post Reply
gkick
Posts: 324
Joined: Wed Aug 07, 2019 5:24 pm
Location: Chile

[Solved] Maths or Logical Issue

Post by gkick »

Hi,

Got the following issue at hands...

STH Standard Hours is the normal working time for an employee and is calculated by
HoursWorked - BaseHours e g 12-8 = 4 hours overtime, however if
HoursWorked - BaseHours e g 3-8 = -5 hours negative overtime which might cancel out legitimate overtime
HSQL does not seem to have some kind of IIF function, so how can one tell the db if the HoursWorked are less then the prescribed BaseHours to return a 0 for this particular row.

Anyone struck something similar?
Last edited by gkick on Sun Dec 22, 2019 5:01 am, edited 1 time in total.
Libre Office 6.4.6 on Windows 10 HSQL 2.51 backend
FJCC
Moderator
Posts: 9248
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: Maths or Logical Issue

Post by FJCC »

You can use a CASE WHEN statement

Code: Select all

CASE WHEN HoursWorked < BaseHours THEN 0 ELSE HoursWorked - BaseHours END
OpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
gkick
Posts: 324
Joined: Wed Aug 07, 2019 5:24 pm
Location: Chile

Re: Maths or Logical Issue

Post by gkick »

Thanks a lot, made my day !
Libre Office 6.4.6 on Windows 10 HSQL 2.51 backend
Post Reply